Android AlarmManager problem with setting & resetting an alarm

When canceling the AlarmManager do not use a PendingIntent with a flag of FLAG_CANCEL_CURRENT.
Instead, cancel the PendingIntent explicitly after canceling the alarm:

am = (AlarmManager) getSystemService(getApplicationContext().ALARM_SERVICE);
Intent i = new Intent(getApplicationContext(),AlarmReceiver.class);
PendingIntent p = PendingIntent.getBroadcast(getApplicationContext(), 0, i, 0);
am.cancel(p);
p.cancel();

Leave a Comment