问题
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