Skip to content

Most visited

Recently visited

navigation

Excessive Wakeups

Wakeups are a mechanism in the AlarmManager API that lets developers set an alarm to wake up a device at a specified time. You app sets a wakeup alarm by calling one of the set() methods in AlarmManager with either the RTC_WAKEUP or ELAPSED_REALTIME_WAKEUP 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 onReceive() or onAlarm() method. If wakeup alarms are triggered excessively, they can drain a device's battery.

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

The AlarmManager was 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 JobScheduler and Firebase JobDispatcher. 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 practices section.

Identify the places in your app where you schedule wakeup alarms and reduce the frequency that those alarms are triggered. Here are some tips:

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.

Best Practices

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 Repeating Alarms.

Don't use AlarmManager to schedule background tasks, especially repeating or network background tasks. Use JobScheduler or Firebase JobDispatcher to schedule background tasks because they offer the following benefits:

For more information, see Intelligent Job-Scheduling.

Don't use AlarmManager 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.

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!

Follow Google Developers on WeChat

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 short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)