Skip to content Skip to sidebar Skip to footer

How To Cancel Multiple Alarm Using Other Activity

Create note Activity from where Alarm trigger! and Alarm delete code in other Activity,it delete only last trigger Alarm means if 3 Alarm are created and I want to delete Alarm 1 i

Solution 1:

The PendingIntent needs to be created exactly as it was when you started the AlarmManager.

Use PendingIntent.FLAG_UPDATE_CURRENT instead of 0 when creating the PendingIntent to cancel the alarm. FLAG_UPDATE_CURRENT is equal to the constant 134217728, not 0.

Solution 2:

Use this code:

PendingIntentpendingIntent= PendingIntent.getBroadcast(this, _id, intent, 0);
        AlarmManageralarmManager= (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
        alarmManager.cancel(pendingIntent);

Hope this helps.

Post a Comment for "How To Cancel Multiple Alarm Using Other Activity"