4

I'm building an alarm clock app in Android. Does AlarmManager automatically handle clock changes between summertime and wintertime or do I need to manage that explicitly?

edit: If an alarm is set where the repeat interval crosses a clock change will that alarm need to be rescheduled?

Leo
  • 6,553
  • 2
  • 29
  • 48

2 Answers2

6

As opposed to what the accepted answer says I saw a different behavior in my app, I have a task running daily a few minutes after midnight.

After a daylight saving time change, the task started running a few minutes after 11:00PM causing the task to return wrong results (the task checks the current date and queries stuff accordingly).

So my answer is - yes, you'll need to manage that explicitly.

EDIT: our task needed to run once a day at a specified time. To solve this issue, we save the last time our app ran, and check that timestamp whenever the task runs again. If the timestamp is not 24h (might be 23h or 25h because of DST change), we abort the AlarmManager and schedule a new one instead. So we have up to 2 "missed" runs a year (we can live with that).

marmor
  • 27,641
  • 11
  • 107
  • 150
-1

AlarmManager will take care of the day light saving. It reset the Timezone info at the beginning of each day taking daylight saving info into consideration.

havexz
  • 9,550
  • 2
  • 33
  • 29
  • So I don't need to reschedule the alarms each day? (See my edit in the original question). – Leo Dec 04 '11 at 19:35
  • 1
    It should work fine as the AlarmManager will re-calculate on the start of every day taking into account the day light saving. – havexz Dec 04 '11 at 19:50
  • 3
    It doesn't - At least not on os 4.0.4: We switched recently and I noticed the alarm fires exactly 1 hour later!! It's set to fire at 19:00 (07:00 pm) and now it fires at 20:00 (08:00 pm). So, It's **NOT** DST-aware... I fully agree with @marmor – Phantômaxx Apr 02 '14 at 18:05
  • 2
    We recently change the time to summer time (2017). I am receiving reports for my app that the Scheduler (which uses `AlarmManager setRepeating` method) is now launching 1 hour late. So yeah, it seems it is *NOT* correctly handled and it looks like it needs to be done manually. – Ferran Negre Apr 03 '17 at 10:53