Difference Between Wakelock And Flag_keep_screen_on?
Solution 1:
A wakelock gives you way more control (Like waking the phone to download something without turning the screen off) and requires your application to hold the wakelock permission.
Therefore FLAG_KEEP_SCREEN_ON
is recommended if all you want is to keep the screen on while your window is visible.
Solution 2:
Wakelock
is vague, since it has many different options. The flag FLAG_KEEP_SCREEN_ON
only does that.
| Flag Value | CPU | Screen | Keyboard |
-----------------------------------------------------
| PARTIAL_WAKE_LOCK | On* | Off | Off |
| SCREEN_DIM_WAKE_LOCK | On | Dim | Off |
| SCREEN_BRIGHT_WAKE_LOCK | On | Bright | Off |
| FULL_WAKE_LOCK | On | Bright | Bright |
Please see wakelock or PowerManager for Android specifics, and other answers for the exact implementation.
Solution 3:
Wake lock is used in background services to keep the CPU running to do work while the screen is off. You should never use wake lock in an activity. To use wake lock, WAKE_LOCK permission must be added in application's manifest file.
FLAG_KEEP_SCREEN_ON is used in activity to keep the screen turned on, which will also keep the CPU on without any special permission, unlike wake lock. You should never use FLAG_KEEP_SCREEN_ON in a service.
Cheers!
Post a Comment for "Difference Between Wakelock And Flag_keep_screen_on?"