Search code examples
javaandroidandroid-4.2-jelly-bean

Android, How to disable lockscreen/screen timeout (API version independent)


I need to disable lockscreen and set screentimeout to never not only in my app but for the phone generaly.

I tried to set the screentimeout to "-1", which worked e.g. on Android 2.3 but not on 4.2 Is there any way to do so?

Settings.System.putString(context.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, "-1");

Solution

  • You can do it in the xml layout file of each activity by adding Android:screenOn="true"