reset screen timeout in android
I'm using the following code to wake the phone's screen:
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "XPAND-IT");
wl.acquire();
After this code runs, I want t开发者_开发技巧o reset the screen timeout to release the wake lock. How can I do it?
I assume you have the following problem:
- The wake lock is acquired
- Some time passes without the user touching the screen
- The wake lock is released
- The screen goes off immediately (or at least too soon) because the screen timeout period started counting when the wake lock was acquired
There's a simple solution for this: Add the flag PowerManager.ON_AFTER_RELEASE
and the timeout is reset when releasing the wake lock.
精彩评论