


While this is fine most of the time, some applications need to keep the screen awake to complete their work. To avoid draining the battery, most devices quickly go to sleep when left idle. * PARTIAL_WAKE_LOCK keeps the CPU running.The Screen Wake Lock API, part of Google's capabilities project, launched in Chrome 84. * SCREEN_DIM_WAKE_LOCK keeps the screen on (but dims it) and the CPU is running. * SCREEN_BRIGHT_WAKE_LOCK keeps the screen all on and the CPU is running. * FULL_WAKE_LOCK keeps the screen all on, the keyboard backlight is on and the CPU is running. To create a Wake Lock, you need to call the newWakeLock of the power manager and specify a WakeLock type: In order to ensure that the service can be executed, a separate Wake Lock needs to be placed.

If you start a service or broadcast an intent in the onReceive handler of the broadcast receiver, it is possible that the serviceīefore starting, the Wake Lock used will be released. It is worth noting that, in this case, the system will use the CPU Wake Lock in the entire onReceive handler of the broadcast receiver. This situation often occurs when the service is started from within the intent receiver, because the intent receiver may receive the intent while the device is sleeping. Screen Wake Lock is usually used to prevent the screen from dimming while the user is watching the screen but rarely interacts with the screen (for example, playing a video).ĬPU Wake Lock is used to prevent the device from entering the sleep state until an operation is performed. It is indeed necessary to use Wake Lock, and use them as little as possible, release them whenever possible. WakeLock can be used to keep the CPU running, prevent the screen from dimming and turning off, and to prevent the keyboard backlight from turning off.Ĭreating and using Wake Lock can have a significant impact on battery consumption caused by apps. WakeLock is a power management system service function that applications can use to control the power state of the device.
#Wake lock power manager android
In order to extend the life of the battery, Android devices will dim the screen after a period of time, then turn off the screen display, and finally stop the CPU.
