Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between RTC and RTC_WAKEUP of AlarmManager

Hello I was reading on android docs about these two constans of AlarmManager but didn't get exactly the difference between them.

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.

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

Thanks in advance.

like image 757
N Sharma Avatar asked Feb 01 '15 12:02

N Sharma


Video Answer


1 Answers

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

RTC and ELAPSED_REALTIME do not wake up the device out of sleep mode. If the device is in sleep mode at the time of the event, nothing immediately happens. You will be notified about missed events when the device wakes up for other reasons (e.g., user presses the power button).

RTC_WAKEUP and ELAPSED_REALTIME_WAKEUP will wake up the device out of sleep mode. If your PendingIntent is a broadcast PendingIntent, Android will keep the device awake long enough for onReceive() to complete. If you have significant work, that you do not want to do in onReceive() (because onReceive() is called on the main application thread), you will need to arrange to keep the device awake long enough for some service of yours to complete the work, such as by using WakefulBroadcastReceiver.

like image 92
CommonsWare Avatar answered Oct 30 '22 02:10

CommonsWare