Skip to content

Most visited

Recently visited

navigation

Stuck Wake Locks

Partial wake locks are a mechanism in the PowerManager API that lets developers keep the CPU running after a device's display turns off (whether due to system timeout or the user pressing the power button). Your app acquires a partial wake lock by calling acquire() with the PARTIAL_WAKE_LOCK flag. A partial wake lock becomes stuck if it is held for a long time while your app is running in the background (no part of your app is visible to the user). This condition drains the device's battery because it prevents the device from entering lower power states. Partial wake locks should be used only when necessary and released as soon as no longer needed.

To help you improve app quality, Android automatically monitors apps for stuck partial wake locks and displays the information in Android Vitals. For information on how the data is collected, see Play Console docs.

If your app has a stuck partial wake lock, you can use the guidance in this page to diagnose and fix the problem.

Fix the problem

Wake locks were introduced in early versions of the Android platform, but over time, many use cases that previously required wake locks are now better served by newer features like JobScheduler and Firebase JobDispatcher. This section contains tips for fixing your wake locks, but in the long term, consider migrating your app to follow the recommendations in the best practices section.

Identify and fix places in your code that acquire a wake lock, such as newWakeLock(int, String) or WakefulBroadcastReceiver. Here are some tips:

After fixing the problem in code, verify that your app correctly releases wake locks by using the following Android tools:

Best Practices

In general, your app should avoid partial wake locks because it is too easy to drain the user's battery. Android provides alternative APIs for almost every use-case that previously required a partial wake lock. One remaining use-case for partial wake locks is to ensure that a music app continues to play when the screen is off. If you are using wake locks to run tasks, consider the following alternatives:

The benefit to using those APIs is that the system intelligently batches and/or defers those tasks based on the power-state of the device.

If you must use partial wake locks, follow these recommendations:

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.