Android How to - Keep Screen On








Question

We would like to know how to keep Screen On.

Answer

//from   ww w  .j  av a2  s.  c  o m
import android.app.Activity;
import android.view.WindowManager;

class ActivityAttrUtils {
  public static void keepScreenOn(final Activity mActivity) {
    mActivity.getWindow().addFlags(
        WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  }
}