Hello all. 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.
+3
A:
The Settings.System provider offers a SCREEN_OFF_TIMEOUT setting that might be what you are looking for.
CommonsWare
2009-07-11 18:19:03
Thanks again Mark!
Tom
2009-07-11 18:39:44
+2
A:
public class HelloWorld extends Activity {
private static final int DELAY = 3000;
int defTimeOut = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// See assets/res/any/layout/hello_world.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.hello_world);
defTimeOut = Settings.System.getInt(getContentResolver(),
Settings.System.SCREEN_OFF_TIMEOUT, DELAY);
Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_OFF_TIMEOUT, DELAY);
}
@Override
protected void onDestroy() {
super.onDestroy();
Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_OFF_TIMEOUT, defTimeOut);
}`enter code here`