I user sets an alarm it will need to send off an intent to set alarm but the user can have as many alarms but each entry can have 14 intents one for starting the alarm and one for the end of the day say and if user wants to delete alarm it needs to fire off intents to delete them but they need to be the exact same so how do i do that.
Intent endAlarmIntent = new Intent(setAndroidAlarmContext, EndTimeAndroid.class);
PendingIntent endIntent = PendingIntent.getBroadcast(setAndroidAlarmContext, 14 , endAlarmIntent, 0);
setAlarm.setRepeating(AlarmManager.RTC_WAKEUP, endSun, daysBetweenAlrm , endIntent);
the 14 in the intent above is so i can find it later so when im ending it i have intent with 14 in it but problem is that if there was two intents two of them could have 14 so it would overright it what be the best way to stop this, get ramdom number and save it to the database and send it in when deleting the intent to have it the same?
In my app the user is also generating an undefined number of alarms, so for each alarm’s
PendingIntentI set the system time to anintlike thisIn order to generate a somewhat-random unique identifier (the
longgets truncated to anintbut that’s fine).And set it as the
PendingIntentunique code that identifies it, like this (using your code):Then in my database I have a field for
alarm_idwith any other data for that alarm so that I can update or cancel that alarm any time I need.I would also do what @ravuya said and use one
Intentand pass in arguments through the extras to tell what type of alarm it is.