Reputation: 3182
I'am developing an android application which has multiple Alarm Managers. They are fired from both using BroadCast Receivers and also some are just triggering after the given time period.
What I want to know is, how I stop/cancel a alarm manager by getting identify among this multiple alarms.
Upvotes: 1
Views: 133
Reputation: 36
AlarmManagers are uniquely identify by its pending intent. go through my demo example
Intent imageFetchingService = new Intent(mContext, ImageFetchingService.class);
PendingIntent imageFetchingPendingIntente = PendingIntent.getService(
mContext, 0, imageFetchingService,
PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) mContext
.getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(imageFetchingPendingIntente);
alarmManager.set(AlarmManager.RTC_WAKEUP, 120000,
imageFetchingPendingIntente);
Upvotes: 2