About the difference between the alarms of type of

2019-05-16 00:58发布

问题:

What is the difference between the alarms of type of RTC_WAKEUP and RTC?

From the documenatation of the AlarmManager, it seems that alarms of RTC will not wake up the device if the device current is asleep, and will not delivered until the next time the device wakes up. But I found that the alarm of type of RTC will still wake up the device, so what's going on?

What I did is to change the type of RTC_WAKEUP to RTC in the AlamrManagerService.java, function setRepeating(), and then set an alarm of 3 minutes from now on, then check the device, you will find that it still could be waken up by the alarm.

回答1:

THere are other instances reporting AlarmManager.RTC seems to wake up the device:

  • AlarmManager.RTC doing too many updates on wakeup
  • Android AlarmManager RTC doesn't pause while device is sleeping
  • Allowing the phone to sleep while using RTC alarm on Android

Each time, the root cause is the same:

Something keeps the device awake (even though the screen is black).
Don't forget that a charging device (connected to power) isn't sleeping.