0

I don't know what i'm doing wrong. I scheduled an AlarmManager that triggers alarm every 10 minutes. I used ELAPSE_REAL_TIME because i don' care that alarm is synchronized with real time. The alarm triggers even if device goes in deep sleep mode and i cannot understand why.

Here is the code:

int minutes = 10;
if ( PendingIntent.getBroadcast( context, MyUtility.ALARM_UNIQUE_ID, i, PendingIntent.FLAG_NO_CREATE ) == null )
{
    AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);                       
    PendingIntent pi = PendingIntent.getBroadcast( context, 0, i, 0);                               
    am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(), 1000 * 60 * minutes, pi);
}

The expected behaviour will be that alarm triggers every 10 minutes from now until devices goes in deep sleep mode and if deep sleep goes one for hours (like when i put airplane mode during night) the alarm won't trigger (until the morning) right?

Vasily Kabunov
  • 6,511
  • 13
  • 49
  • 53
on35
  • 39
  • 5
  • check this one http://androidtechlaunch.blogspot.in/2013/09/android-and-intent-service-for.html – nilkash Sep 18 '13 at 06:28
  • So here in above example you can start or stop your service as you want. – nilkash Sep 18 '13 at 06:30
  • I do have a service that schedules the Alarm so this might be a solution. But if this is the correct behaviour (alarm fires even in deep sleep mode and so wakes up device) what's the difference if i use ELAPSED_REALTIME_WAKEUP? – on35 Sep 18 '13 at 06:38
  • ELAPSED_REALTIME_WAKEUP is trigger the alarm since boot see this one nice explaination timehttp://stackoverflow.com/questions/5938213/android-alarmmanager-rtc-wakeup-vs-elapsed-realtime-wakeup – nilkash Sep 18 '13 at 06:51
  • See this may be helps you http://stackoverflow.com/questions/5102073/android-alarm-what-is-the-difference-between-four-types-of-alarm-that-alarmmanag – nilkash Sep 18 '13 at 06:53
  • I saw this question before posting but according to this posst and android documentation: "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." ..but if still fires even in deep sleep – on35 Sep 18 '13 at 06:57

0 Answers0