1

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?

Adil Hussain
  • 24,783
  • 20
  • 95
  • 134

2 Answers2

2

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.

Community
  • 1
  • 1
Pankaj Kumar
  • 78,055
  • 25
  • 161
  • 180
  • I think it depends on the alarm type u use. RTC could trigger if the time is changed manually by the user, but ElapsedRealTime should not. – Kedu Oct 28 '14 at 18:49
  • The ACTION_TIME_TICK is not intented for such a use-case - it's received every second! – Derek K Feb 20 '21 at 09:06
1

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!

Community
  • 1
  • 1
Adil Hussain
  • 24,783
  • 20
  • 95
  • 134