Stuck partial wake locks
Stay organized with collections
Save and categorize content based on your preferences.
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, or by using other APIs that acquire wake locks.
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.
If your app has a stuck partial wake lock, you can use the guidance in this page
to diagnose and fix the problem.
Detect the problem
You may not always know that your app's partial wake locks are stuck.
If you have already published your app,
Android vitals can help make you aware of the problem.
Android vitals
Android vitals can help improve your app's performance by alerting you via the
Play Console when your app is
exhibiting stuck partial wake locks. Android vitals reports partial wake locks
as stuck when at least one, hour-long, while in the background, partial wake
lock occurs in a 24-hour period.
The number of battery sessions displayed is an aggregate for all measured users
of the app. For information on how Google Play collects Android vitals data, see
the
Play Console
documentation.
Once you're aware that your app has stuck partial wake locks,
your next step is to address the issue.
Fix the problem
Because wake locks can drain the device battery, you shouldn't use wake
locks if there's an alternative. The
Choose the right API to keep the device awake
documentation can help you find the best solution for your app.
If you do need to use a wake lock, follow wake lock best practices
to make sure your wake locks don't hurt device efficiency. In particular,
make sure every device you acquire is released, and release the lock as quickly
as possible.
After fixing the problem in code, you can verify your fixes by using local
wake lock debugging tools.
See also
Recommended for you
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-04-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-04-14 UTC."],[],[],null,["# Stuck partial wake locks\n\nPartial wake locks are a mechanism in the\n[`PowerManager`](/reference/android/os/PowerManager) API\nthat lets developers keep the CPU running after a device's display turns off\n(whether due to system timeout or the user pressing the power button). Your\napp acquires a partial wake lock by calling\n[`acquire()`](/reference/android/os/PowerManager.WakeLock#acquire())\nwith the\n[`PARTIAL_WAKE_LOCK`](/reference/android/os/PowerManager#PARTIAL_WAKE_LOCK)\nflag, or by using [other APIs that acquire wake locks](/develop/background-work/background-tasks/awake/wakelock/identify-wls).\nA partial wake lock becomes *stuck* if it is held for a long time while\nyour app is running in the\nbackground (no part of your app is visible to the user). This condition drains\nthe device's battery because it prevents the device from entering lower power\nstates. Partial wake locks should be used only when necessary and released as\nsoon as no longer needed.\n\nIf your app has a stuck partial wake lock, you can use the guidance in this page\nto diagnose and fix the problem.\n\nDetect the problem\n------------------\n\nYou may not always know that your app's partial wake locks are stuck.\nIf you have already published your app,\nAndroid vitals can help make you aware of the problem.\n\n### Android vitals\n\nAndroid vitals can help improve your app's performance by alerting you via the\n[Play Console](https://play.google.com/console/) when your app is\nexhibiting stuck partial wake locks. Android vitals reports partial wake locks\nas stuck when at least one, hour-long, while in the background, partial wake\nlock occurs in a 24-hour period.\n\nThe number of battery sessions displayed is an aggregate for all measured users\nof the app. For information on how Google Play collects Android vitals data, see\nthe\n[Play Console](https://support.google.com/googleplay/android-developer/answer/7385505)\ndocumentation.\n\nOnce you're aware that your app has stuck partial wake locks,\nyour next step is to address the issue.\n\nFix the problem\n---------------\n\nBecause wake locks can drain the device battery, you shouldn't use wake\nlocks if there's an alternative. The\n[Choose the right API to keep the device awake](/develop/background-work/background-tasks/awake)\ndocumentation can help you find the best solution for your app.\n\nIf you do need to use a wake lock, [follow wake lock best practices](/develop/background-work/background-tasks/awake/wakelock/best-practices)\nto make sure your wake locks don't hurt device efficiency. In particular,\nmake sure every device you acquire is released, and release the lock as quickly\nas possible.\n\nAfter fixing the problem in code, you can verify your fixes by using [local\nwake lock debugging tools](/develop/background-work/background-tasks/awake/wakelock/debug-locally).\n\nSee also\n--------\n\n- [Excessive partial wake locks (beta)](/topic/performance/vitals/excessive-wakelock)\n- [Wake lock documentation](/develop/background-work/background-tasks/awake/wakelock)\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Frozen frames](/topic/performance/vitals/render#frozen-frames)\n- [Run benchmarks in Continuous Integration](/topic/performance/benchmarking/benchmarking-in-ci)\n- [Create and measure Baseline Profiles without Macrobenchmark](/topic/performance/baselineprofiles/manually-create-measure)"]]