I'm trying to make my widget update periods configurable through the use of the AlarmManager
. I've now got this working by implementing the onReceive()
method in my AppWidgetProvider
which in turn calls the onUpdate()
method of the AppWidgetProvider when it receives a broadcast of my alarm. This appears to be working, though I am still struggling to understand certain scenarios.
Last night, I configured the alarm to update every hour and to not wake the phone up. As you can see from the out adb shell dumpsys alarm
below, I've successfully registered a RTC alarm to execute every hour:
RTC #1: Alarm{40b354b0 type 1 com.my.app}
type=1 when=+59m40s6ms repeatInterval=3600000 count=1
operation=PendingIntent{40c11e70: PendingIntentRecord{40e2b290 com.my.app broadcastIntent}}
Anyway, I unplugged my phone, turned the screen off and went to bed. In my onReceive()
method, I output log messages to a file to ensure I capture what is going on. This morning I took a look at the log and discovered that my onRecieve() method fired every hour without fail. It never slept through a single alarm.
Why is this the case? While I suppose its possible other processes or alarms are waking up my phone, it seems suspicious. Can anyone offer any information or advice?
Finally, does anyone know what the count=1
means in my output above?