Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens to undelivered AlarmManager repeating alarms when phone wakes up?

If we schedule an inexact repeating alarm with AlarmManager.setInexactRepeating to be fired every hour, for example, what happens if the phone is in standby for 4 hours and then it is woken up? Does the system deliver 4 alarms in a row for the same PendingIntent or does it deliver only a single alarm?

EDIT: reading the documentation with more attention, the set(int, long, android.app.PendingIntent) method documentation says: Alarm intents are delivered with a data extra of type int called Intent.EXTRA_ALARM_COUNT that indicates how many past alarm events have been accumulated into this intent broadcast. Recurring alarms that have gone undelivered because the phone was asleep may have a count greater than one when delivered. So, when the phone comes out of standby, only one alarm will be delivered, with an intent extra that contains the number of missed alarms.

like image 893
Gianni Costanzi Avatar asked Nov 12 '22 23:11

Gianni Costanzi


1 Answers

Reading the documentation with more attention, the set(int, long, android.app.PendingIntent) method documentation says: Alarm intents are delivered with a data extra of type int called Intent.EXTRA_ALARM_COUNT that indicates how many past alarm events have been accumulated into this intent broadcast. Recurring alarms that have gone undelivered because the phone was asleep may have a count greater than one when delivered. So, when the phone comes out of standby, only one alarm will be delivered, with an intent extra that contains the number of missed alarms.

like image 54
Gianni Costanzi Avatar answered Dec 24 '22 03:12

Gianni Costanzi