There is a list of tasks. For tasks, you can create multiple reminders. Tasks are created in one activity, their entire list is displayed through a ListView in another. In the activity with ListView, created a context menu that removes the record from the database. But how can I delete all her reminders? The function code that creates the alarm:

private void StartAlarm(long timeAlarm) { Random random_idAlarm = new Random(System.currentTimeMillis()); final int id_alarm = random_idAlarm.nextInt(214748364); alarm_for_affair = (AlarmManager)getSystemService(Context.ALARM_SERVICE); Intent myintent = myintent = new Intent(CreateAffairActivity.this, AlarmReceiver.class); myintent.putExtra("name", name_affair.getText().toString()); myintent.putExtra("time", time_affair.getText().toString()); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id_alarm, myintent, PendingIntent.FLAG_ONE_SHOT); // конфигурация для напоминания alarm_for_affair.set(AlarmManager.RTC_WAKEUP, timeAlarm, pendingIntent); // запуск таймера } 

where timeAlarm is the response time. AlarmReceiver.class - creates notification. I realized that I had to send all PendingIntent data to the AlarmManager, deleting it with cancel. Just how can I store the data of all intents for recording and still not transfer them to another activity.

  • It is enough to save id_alarm , for example, in Preferences , and when deleting, re-create PendingIntent with the same id_alarm - Serodv
  • @Serodv and Preferences stores the values ​​as well as the database? when closing the application, the value of the variable is not lost? Just do not know what it is - Vlad Pech
  • as in a regular file and easier to access startandroid.ru/ru/uroki/vse-uroki-spiskom/… - Serodv

0