Leo
Leo

Reputation: 6571

Does Android AlarmManager handle daylight saving changes?

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?

Upvotes: 4

Views: 4531

Answers (2)

marmor
marmor

Reputation: 28239

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).

Upvotes: 7

havexz
havexz

Reputation: 9590

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.

Upvotes: -1

Related Questions