Android的AlarmManager和DST /时区/时间的变化?

编程入门 行业动态 更新时间:2024-10-24 19:30:08
本文介绍了Android的AlarmManager和DST /时区/时间的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我编码闹钟应用程序,我想知道发生什么事,当我在时间上午02时59分设置一些报警与AlarmManager为例(这不是我的闹钟时间,这是唯一的一次,当我设置一些报警)和凌晨3:00将有来自夏时制时间自动切换到冬季(DST)。我的计划报警,会发生什么?我发现没有什么文档,它不是那么容易测试,至少我要更改日期,等待几个小时......我没有这么耐心;)

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

接下来的问题 - 我也很好奇,会发生什么我报警与AlarmManager设置当用户更改时区。这是幸运pretty容易测试,我发现,Android是pretty智能,并自动重新安排报警。所以,当我在时区为例如9:00,我设置10:00报警,并切换时区(+1小时),其中实际时间是上午10点,重新安排的android我的闹钟到11点,符合市场预期。这是很细的,但是,我并没有发现什么也文档中...

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

任何人有更多的官方信息? THX

Anybody has more official information? Thx

推荐答案

RTC 和 RTC_WAKEUP 使用 System.currentTimeMillis的()作为时基,这是UTC时间,因此是独立的时区的变化,夏令时的变化,等等。

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.

更多推荐

Android的AlarmManager和DST /时区/时间的变化?

本文发布于:2023-11-27 10:20:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637674.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时区   时间   Android   AlarmManager   DST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!