AlarmManager - expected behaviour of alarm when device time is changed?

天涯浪子 提交于 2019-12-11 07:53:40

问题


Assume I set an alarm using the AlarmManager.set(int type, long triggerAtMillis, PendingIntent operation) method for 2pm today and the current time is 1pm. Now, if I change the time on the device to be 3pm (i.e. 3pm today or any day in the future), what should happen to my alarm? Should it trigger?


回答1:


No that will not triggered by AlarmManager. So you should listen about time change actions and re-create the alarm.

Those actions are

Intent.ACTION_TIME_TICK
Intent.ACTION_TIMEZONE_CHANGED
Intent.ACTION_TIME_CHANGED

does Alarm Manager persist even after reboot? is a better answer to understand your problem and resolve that.




回答2:


Please ignore question. I've found my answer here and a suggested solution:

Date and time change listener in Android?

If anyone has an alternative answer or solution, please do post!



来源:https://stackoverflow.com/questions/18463507/alarmmanager-expected-behaviour-of-alarm-when-device-time-is-changed

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