I'm facing a problem using Wake lock through PowerManager API. Currently, i have a service and a broadcast receiver.
My service has 2 main roles :
I'm using Mark murphy's cwac-wakeful module to achieve that and it works just fine.
The problem is : the screen turns on and off too fast for the user to see it.
Here is what's happening when the alarm intent is launched (for the second role/case) :
As you have probably understood. The problem is, the lock is released too fast after the service finishes so i can just see the screen turning on and off in less that one second. I thought that using the ON_AFTER_RELEASE (the doc says : "If this flag is set, the user activity timer will be reset when the WakeLock is released, causing the illumination to remain on a bit longer. This can be used to reduce flicker if you are cycling between wake lock conditions. ") would have solved my problem, but no.
When googling, i found a solution that consists in :
Then my question is how can i maintain the screen on for a few seconds (say 10/15 sec) like when i receive an sms, what is the best solution to achieve that ?
Any help would be greatly appreciated, and thanks in advance !
I had a similar situation in that my app was shutting down immediately after I released a WakeLock. I think I applied the same logic to it that you did, but I used a FULL_WAKE_LOCK with the other options PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE. This seemed to do the trick for me in my "GameTime" timer application. I know this was posted a while a ago, but maybe it would provide some help to someone!
There is a line in API documentation that states: "In addition, you can add two more flags, which affect behavior of the screen only. These flags have no effect when combined with a PARTIAL_WAKE_LOCK." I wonder if SCREEN_DIM_WAKE_LOCK counts as a PARTIAL WAKE LOCK? (undocumented 'feature')
API located here: http://developer.android.com/reference/android/os/PowerManager.html
I think you provide the answer:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.