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
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.
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
WorkManager.
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: