Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android AlarmManager and DST/Timezone/Time change?

I'm coding an alarm clock application, and i would like to know what happens, when I set some alarm with AlarmManager for example at time 2:59am (this is not time of my alarm, this is only time WHEN i set some alarm), and at 3:00am there will be automatic time change from summer time to winter (DST). What happens with my scheduled alarm? I found nothing in docs, and it's not so easy to test, at least I must change dates and wait few hours...I'm not so patient ;)

Next problem - I was also curious, what happens with my alarms set with AlarmManager when user changes timezone. This was luckily pretty easy to test, and I found, that android is pretty "intelligent" and reschedule alarm automatically. So when in my timezone is for example 9:00 and i set alarm on 10:00, and switch timezone (+1 hours) where actual time is 10:00, android reschedule my alarm to 11:00, as expected. This is very fine, however, i didn't found also anything in docs...

Anybody has more official information? Thx

like image 561
qkx Avatar asked Jul 25 '12 13:07

qkx


2 Answers

RTC and RTC_WAKEUP use System.currentTimeMillis() as the timebase, which is in UTC time and therefore is independent of time zone changes, daylight savings time changes, etc.

like image 163
CommonsWare Avatar answered Oct 14 '22 06:10

CommonsWare


Alarm will only depend on System time. Alarm will not be affected by day light savings, only the system time changes. Alarm will be according to the system time and whichever zone, dst the device is in (or will be in)

like image 3
Gautham Avatar answered Oct 14 '22 08:10

Gautham