sleep mode ?!

#1

hi all

is there a way to turn sleep mode off in android? o a way to control its timer programmatically?
I really need my app to run all the time (or at least 1 hr) and devices only allow for 10 mins max on the sleep mode timer

hope u can help me!

thanx!

.r

1 Like
#2

In the coe Android / Java SDK, you would use a wake lock… I’m not sure if there’s a call to that from oFAndroid…

#3

so if you include this in your manifest you can set system settings from the Main Activity:

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

you can do something like this to set the system settings

  
android.provider.Settings.System.putInt(getContentResolver(),android.provider.Settings.System.SCREEN_BRIGHTNESS, brightness);  

You can look over all the system settings you can set here:http://developer.android.com/reference/android/provider/Settings.System.html.

So you can set SCREEN_OFF_TIMEOUT and a few other things.

1 Like
#4

actually once you’ve set the permission in the manifest you can call:

ofxAndroidLockScreenSleep();

and

ofxAndroidUnlockScreenSleep();

from c++ code to lock and unlock sleep

1 Like
Is there an example or instructions somewhere on the "right" way to handle Android interrupting an OF program?
#5

thank you both!!
ofxAndroidUtils FTW!

* )
.r