Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Screen Timeout

I know its possible to use a wakelock to hold the screen, cpu, ect on but how can I programmatically change the "Screen Timeout" setting on an Android phone.

like image 241
Tom Avatar asked Jul 11 '09 17:07

Tom


People also ask

How do I keep my Android from going to Sleep?

Enable stay awake modeFrom the settings page navigate to > About Tablet > Software Information. Then tap the "Build Number" 7 times to enable developer mode. Developers mode is where you'll find the Stay Awake option, toggle to enable.


2 Answers

The Settings.System provider offers a SCREEN_OFF_TIMEOUT setting that might be what you are looking for.

like image 143
CommonsWare Avatar answered Sep 17 '22 14:09

CommonsWare


Above is correct:

Settings.System.putInt(getContentResolver(),Settings.System.SCREEN_OFF_TIMEOUT, DELAY); 

But also include permission in manifest:

android:name="android.permission.WRITE_SETTINGS"
like image 34
Shadab Avatar answered Sep 21 '22 14:09

Shadab