问题
I've got a service that I run every 30 minutes via AlarmManager.RTC
. If the device is asleep long enough for the service to be called twice (and thus have both of them be rescsheduled), when it wakes up, it fires off the service twice at once.
The desired behavior is for the AlarmManager
to just fire off one Intent
when it wakes up. How can I accomplish this?
回答1:
Try this:
PendingIntent.FLAG_UPDATE_CURRENT
回答2:
Have you cancel the old one of Alarm Manager. If no means, just cancel the old one with PendingIntent
Have a look at this Commonsware Example
来源:https://stackoverflow.com/questions/9081988/alarmmanager-rtc-doing-too-many-updates-on-wakeup