You should create an similar PendingIntent
used when scheduling the Alarm
to cancel the repeat Alarm
When setting the alarm you have created PendingIntent
as PendingIntent.getBroadcast
but in when cancel its PendingIntent.getService
. This is wrong
Create a similar intent to cancel the alarm
Intent notifyCycle = new Intent(context, NotifyCycleChange.class);
PendingIntent pendingUpdateIntent = PendingIntent.getBroadcast(getApplicationContext(), (int) id, notifyCycle, PendingIntent.FLAG_UPDATE_CURRENT);
And then , cancel the alarm
AlarmManager alarmManager = (AlarmManager)getApplicationContext().getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(pendingUpdateIntent);