Android: Change Delay Before The Phone Is Put To Sleep While My App Is Running
This question sounds so easy I can't believe I can't find information on it (maybe I have the wrong key words in mind...) I'm looking for a way to change the delay before the phone
Solution 1:
Create a Timer
object and release()
your wake lock in the timer task. I'm relatively sure you can release a lock in a worker thread, but worst case, you'd need to use runOnUiThread
if I'm incorrect.
Be sure to handle the case when onPause()
is called and cancel your timer in that case and release the lock immediately.
In general, I'm not a fan of wake locks, but if this is to make your boss happy, wake-lock away.
EDIT: Btw, the system setting for the UI timeout is accessible by apps: SCREEN_OFF_TIMEOUT
in android.provider.Settings.System
. But really, this is for private applications only, public applications have no business changing this value.
Post a Comment for "Android: Change Delay Before The Phone Is Put To Sleep While My App Is Running"