Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Alarm What is the difference between four types of Alarm that AlarmManager provides and when to use what?

Tags:

android

alarm

I want to know the difference between RTC, RTC_WAKEUP, ELAPSED_REALTIME, ELAPSED_REALTIME_WAKEUP.
I want to write an alarm application where I will set alarm and close my application and expect for alarm for the time set.
There will be multiple alarms. Right now I am writing for emulator but later will test on device. In emulator, once I set the alarm and close the emulator and restart it, then will it be cleared, as I find with RTC, RTC_WAKEUP and ELAPSED_REALTIME. I am confused. Should I used ELAPSED_REALTIME_WAKEUP? I have not seen any tutorial using ELAPSED_REALTIME_WAKEUP. please explain. Thanks.

like image 766
Shaista Naaz Avatar asked Feb 24 '11 08:02

Shaista Naaz


2 Answers

ELAPSED_REALTIME

Alarm time in SystemClock.elapsedRealtime() (time since boot, including sleep). This alarm does not wake the device up; if it goes off while the device is asleep, it will not be delivered until the next time the device wakes up.

ELAPSED_REALTIME_WAKEUP

Alarm time in SystemClock.elapsedRealtime() (time since boot, including sleep), which will wake up the device when it goes off.

RTC

Alarm time in System.currentTimeMillis() (wall clock time in UTC). This alarm does not wake the device up; if it goes off while the device is asleep, it will not be delivered until the next time the device wakes up.

RTC_WAKEUP

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

like image 159
Andrew Kovzel Avatar answered Oct 12 '22 23:10

Andrew Kovzel


Types of Alarms :

  • ELAPSED_REALTIME – Fires the pending intent after the specified length of time since device boot. If the device is asleep, it fires when the device is next awake.
  • ELAPSED_REALTIME_WAKEUP – Fires the pending intent after the specified length of time since device boot. It wakes up the device if it is asleep.
  • RTC – Fires the pending intent at a specified time. If the device is asleep, it will not be delivered until the next time the device wakes up.
  • RTC_WAKEUP – Fires the pending intent at a specified time, waking up the device if asleep.
like image 32
pathe.kiran Avatar answered Oct 13 '22 01:10

pathe.kiran