0

I am storing tasks in database with unique ID. And there are 4 different activities that insert and/or delete tasks from database. Now I want to set alarm for these tasks with task_id as request code in PendingIntent. The alarm set from any of the 4 activities. And when task is deleted then Can I cancel the alarm using the task_id (request code).

As I have mentioned alarm has to be set and cancel from 4 activities, I want to make set and cacek alarm as Util function so that I can avoid code duplication.

RSCoder
  • 1
  • 1

1 Answers1

0

Retrieve the PendingIntent you have created using the unique task_id(Refer http://developer.android.com/reference/android/app/PendingIntent.html#getBroadcast(android.content.Context, int, android.content.Intent, int)). Now cancel the Alarm using http://developer.android.com/reference/android/app/AlarmManager.html#cancel(android.app.PendingIntent)

Febi M Felix
  • 125
  • 1
  • 2
  • 8