RTC和AlarmManager的RTC_WAKEUP有什么区别

What is the difference between RTC and RTC_WAKEUP of AlarmManager

您好,我正在阅读有关 AlarmManager 的这两个常量的 android 文档,但没有弄清楚它们之间的确切区别。

RTC Alarm time in System.currentTimeMillis() (wall clock time in UTC).

RTC_WAKEUP Alarm time in System.currentTimeMillis() (wall clock time in UTC), which will wake up the device when it goes off.

当设备处于睡眠模式时,RTC 不会唤醒设备并触发 PendingIntent 吗?

提前致谢。

Does not RTC wake up the device and fire the PendingIntent when device is in sleeping mode ?

RTCELAPSED_REALTIME 不会将设备从睡眠模式唤醒。如果设备在事件发生时处于睡眠模式,则不会立即发生任何事情。当设备因其他原因(例如,用户按下电源按钮)唤醒时,您将收到有关错过事件的通知。

RTC_WAKEUPELAPSED_REALTIME_WAKEUP 会将设备从睡眠模式唤醒。如果您的 PendingIntent 是广播 PendingIntent,Android 将使设备保持唤醒状态足够长的时间,以便 onReceive() 完成。如果你有重要的工作,你不想在 onReceive() 中做(因为 onReceive() 在主应用程序线程上调用),你需要安排让设备保持足够长的时间以提供一些服务完成工作,例如使用 WakefulBroadcastReceiver.