AlarmManager.RTC doing too many updates on wakeup

ⅰ亾dé卋堺 提交于 2019-12-12 03:09:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!