0

Do you need keep your phone keep on for coding better ?

In MainActivity.java we usually have this

File: MainActivity.java

package com.client;

import com.facebook.react.ReactActivity;

public class MainActivity extends ReactActivity {
  
   /**
   * Returns the name of the main component registered from JavaScript. This is used to schedule
   * rendering of the component.
   */

  @Override
  protected String getMainComponentName() {
    return "client";
  }


}

You can add some lines for keep your phone always on for coding better, this lines the code won't let your phone wake down.

Solution:

package com.client;

import com.facebook.react.ReactActivity;
import android.os.Bundle;
import android.view.WindowManager;

public class MainActivity extends ReactActivity {
  
   /**
   * Returns the name of the main component registered from JavaScript. This is used to schedule
   * rendering of the component.
   */

  @Override
  protected String getMainComponentName() {
    return "client";
  }

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.getWindow().
      addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  }

}

Wellerson
  • 167
  • 1
  • 6

0 Answers0