2

I have an alarm that works fine if i am interacting(using) with my application but it dose not works if I set it for next day and not interacting with my app.Therefore I am getting doubt is this because my application process is not running at that time.

here is what I am doing

    Calendar calSet = Calendar.getInstance();
    calSet.set(Calendar.HOUR_OF_DAY, selectedhour);
    calSet.set(Calendar.MINUTE, selectedminute);
    calSet.set(Calendar.YEAR, year);
    calSet.set(Calendar.MONTH, monthOfYear);
    calSet.set(Calendar.DATE, dayOfMonth);
    alarm = new Intent(ActivityA.this, Service.class);
    pendingIntent = PendingIntent.getService(getApplicationContext(), i++,alarm, 1);
    alarmanager.set(AlarmManager.RTC_WAKEUP, calSet.getTimeInMillis(),pendingIntent);  
Shakeeb Ayaz
  • 6,200
  • 6
  • 45
  • 64
  • 1
    From what I know, `AlarmManager` will just fire an alarm whether your app is running or not. The question should be more like, if the fired alarm is processed by your app or not... – Andrew T. Oct 29 '13 at 04:35
  • Check this : http://stackoverflow.com/questions/14041208/how-to-reset-alarm-if-app-is-force-closed-in-android and http://stackoverflow.com/questions/7597358/android-alarmmanager-did-not-work-after-process-stops – Siddharth_Vyas Oct 29 '13 at 04:35

1 Answers1

1

Yes if the phone is rebooted you will lose any AlarmManager intents you have registered. To get around this you should create a broadcast receiver for BOOT_COMPLETED. In the onRecieve() event for your receiver you'll need to re-register any alarms you had registered previously.

However, if your process is only killed and the phone hasn't been rebooted, your alarm should still fire.

This may help you: http://developer.android.com/training/scheduling/alarms.html#boot

jmorris
  • 388
  • 4
  • 6