I'm trying to cancel broadcast at specific event
I have the following code to set the AlarmManager
done.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(getApplicationContext(),NotificationReciever.class); // go to NotificationReciever
i.putExtra("id",getIntent().getStringExtra("id")); //send id that same id own each item in database
Toast.makeText(getBaseContext(),getIntent().getStringExtra("id"),Toast.LENGTH_SHORT).show();
PendingIntent pendingIntent=PendingIntent.getBroadcast(getApplicationContext(),(int)id,
i,PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager= (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar2.getTimeInMillis(),pendingIntent); //go to other activity must be changed to proper notificaton
Reminder.super.onBackPressed();
}
});
When I want to delete an AlarmManager ...
Intent i=new Intent(getApplicationContext(),NotificationReciever.class);
PendingIntent pendingIntent=PendingIntent.getBroadcast(getApplicationContext()
,Integer.parseInt(notesData.getID())
,i
,PendingIntent.FLAG_UPDATE_CURRENT);
pendingIntent.cancel();
AlarmManager alarmManager= (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.cancel(pendingIntent);
but it doesn't cancel the AlarmManager, what's the problem?