Wakeups are a mechanism in the
AlarmManager API that
lets developers set an alarm to wake up a device at a specified time. Your app
sets a wakeup alarm by calling one of the
set() methods in
flag. When a wakeup alarm is triggered, the device comes out of low-power mode
and holds a partial wake lock while executing the alarm's
method. If wakeup alarms are triggered excessively, they can drain a device's
To help you improve app quality, Android automatically monitors apps for excessive wakeup alarms and displays the information in Android vitals. For information on how the data is collected, see Play Console docs.
If your app is waking up the device excessively, you can use the guidance in this page to diagnose and fix the problem.
Fix the problem
introduced in early versions of the Android platform, but over time, many use
cases that previously required
AlarmManager are now
better served by newer features like
This section contains tips for reducing wake up alarms, but in the long term,
consider migrating your app to follow the recommendations in the best
Identify the places in your app where you schedule wakeup alarms and reduce the frequency that those alarms are triggered. Here are some tips:
We recommend including your package, class, or method name in your alarm's tag name so that you can easily identify the location in your source where the alarm was set. Here are some additional tips:
- Leave out any personally identifying information (PII) in the name, such as
an email address. Otherwise, the device logs
_UNKNOWNinstead of the alarm name.
- Don't get the class or method name programmatically, for example by calling
getName(), because it could get obfuscated by Proguard. Instead use a hard-coded string.
- Don't add a counter or unique identifiers to alarm tags. The system will not be able to aggregate alarms that are set that way because they all have unique identifiers.
- Leave out any personally identifying information (PII) in the name, such as an email address. Otherwise, the device logs
After fixing the problem, verify that your wakeup alarms are working as expected by running the following ADB command:
adb shell dumpsys alarm
This command provides information about the status of the alarm system service on the device. For more information, see dumpsys.
Use wakeup alarms only if your app needs to perform an user facing operation (such as posting a notification or alerting the user). For a list of AlarmManager best practices, see Scheduling Alarms.
- batching - jobs are combined so that battery consumption is reduced
- persistence - if the device is rebooted, scheduled WorkManager jobs run after the reboot finishes
- criteria - jobs can run based on conditions, such as whether or not the device is charging or WiFi is available
For more information, see Guide to background processing.
to schedule timing operations that are valid only while the app is running (in
other words, the timing operation should be canceled when the user exits the
app). In those situations, use the
Handler class because it is
easier to use and much more efficient.