Android的AlarmManager - RTC_WAKEUP VS ELAPSED_REALTIME_WAKEUP [英] Android AlarmManager - RTC_WAKEUP vs ELAPSED_REALTIME_WAKEUP
问题描述
能否有人向我解释之间的 AlarmManager.RTC_WAKEUP
和 AlarmManager.ELAPSED_REALTIME_WAKEUP
的区别?我已阅读文档,但还是没有真正理解使用一个比其他的含义。
Can someone explain to me the difference between AlarmManager.RTC_WAKEUP
and AlarmManager.ELAPSED_REALTIME_WAKEUP
? I have read the documentation but still don't really understand the implication of using one over the other.
例如code:
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
scheduledAlarmTime,
pendingIntent);
alarmManager.set(AlarmManager.RTC_WAKEUP,
scheduledAlarmTime,
pendingIntent);
如何将不同的两行code执行?如果将这两行的code执行相对于彼此?
How different will the two lines of code execute? When will those two lines of code execute relative to each other?
我AP preciate你的帮助。
I appreciate your help.
推荐答案
AlarmManager.ELAPSED_REALTIME_WAKEUP
类型用于触发,因为开机时间报警:
AlarmManager.ELAPSED_REALTIME_WAKEUP
type is used to trigger the alarm since boot time:
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, 600000, pendingIntent);
实际上拨打了报警熄灭的 10的设备启动之后分钟。
存在一个开始运行时,该设备启动时,测量器件的正常运行时间的计时器,这是根据该设备的正常运行时间触发你报警的类型。
There is a timer that starts running when the device boots up to measure the uptime of the device and this is the type that triggers your alarm according to the uptime of the device.
然而, AlarmManager.RTC_WAKEUP
将根据时钟的时间触发警报。例如,如果你做的:
Whereas, AlarmManager.RTC_WAKEUP
will trigger the alarm according to the time of the clock. For example if you do:
int thirtySecondsFromNow = System.currentTimeMillis() + 30 * 1000;
alarmManager.set(AlarmManager.RTC_WAKEUP, thirtySecondsFromNow , pendingIntent);
这一点,在另一方面,将触发报警<强30秒内从现在。
AlarmManager.ELAPSED_REALTIME_WAKEUP
类型很少使用比较 AlarmManager.RTC_WAKEUP
。
AlarmManager.ELAPSED_REALTIME_WAKEUP
type is rarely used compared to AlarmManager.RTC_WAKEUP
.
这篇关于Android的AlarmManager - RTC_WAKEUP VS ELAPSED_REALTIME_WAKEUP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!