-2

I am trying to disable automatic screen lock of my phone while application running. I used the below permissions and code,

<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>

getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

The phone automatic lock is disabled but, the display light is off (which is set the display time out in settings).

How can I enable the display also?

earthw0rmjim
  • 19,027
  • 9
  • 49
  • 63
Vineesh TP
  • 7,755
  • 12
  • 66
  • 130

1 Answers1

3

Add the WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON flag to keep the screen on:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
earthw0rmjim
  • 19,027
  • 9
  • 49
  • 63