Reputation: 2561
I set up an alarm for my PendingIntent. Now I want to show in my activity, if this alarm is set or not.
Intent service = new Intent(context, MyService.class);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, service, 0);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, firstStart, interval, pendingIntent);
Is there any way to check is this alarm is set?
Upvotes: 1
Views: 92
Reputation: 95568
You can't query the AlarmManager
to find out if the alarm is set. You pretty much need to remember yourself. You can store something in shared preferences to indicate that you set the alarm. However, once the phone is restarted your alarms are gone, so you also need to either reschedule the alarms on a reboot OR clear your preferences to indicate the alarm is no longer set.
Unfortunately, this is one of those things that Android really lacks (a way to query the alarmManager
).
Upvotes: 2