bluediapente bluediapente - 5 months ago 37
Android Question

Android: Get all PendingIntents set with AlarmManager

I'm setting an alarm like this:

alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime, pendingEvent);

I'm interested in removing all the alarms that where previously set, clearing them.

Is there a way for me to do that or to get all the alarms that are currently set so that I can delete them manually ?


You need to create your pending intent and then cancel it

 AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    Intent updateServiceIntent = new Intent(context, MyPendingIntentService.class);
    PendingIntent pendingUpdateIntent = PendingIntent.getService(context, 0, updateServiceIntent, 0);

    // Cancel alarms
    try {
    } catch (Exception e) {
        Log.e(TAG, "AlarmManager update was not canceled. " + e.toString());