I am setting some events through AlarmManager. below is the code.
AlarmManager AM =(AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent();
intent.setAction(Constants.ALARM_ACTION);
intent.putExtra(Constants.EXTRA_DATA1, data[0]);
intent.putExtra(Constants.EXTRA_DATA2, data[1]);
long selectedTime = Long.parseLong(data[2]);
PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, intent,0);
AM.set(AlarmManager.RTC,selectedTime, pi);
I want to save each event into database. and when user want to see history of events from the app i can show all the events, when if user choose one event i can be able to delete/reset it.
I solved this my self saving data which is i am passing to this pending itent, and the request code which is second param of the getBroadcast method, and then getting the same from database when i want to cancel the event triggered by AlarmManager.cancel method.
By using unique request code for every event , we can reset or cancel events with the request code