I am adding an event to my schedule list and alarm has been fixed to that event. I have to repeat alarm for every one minute, from the before fi开发者_运维知识库ve minutes of event ending time. In below conditions I have to remove or cancel alarm for particular event.
- When I delete event from my schedule.
- Event placed in schedules but I don't want alarm for event.
I am following concepts like sqlite database, Alarm manger, Services. I am confusing little bit using Services and pendingIntent. So, please suggest me the right way to approach my requirement.
You need to use the method cancel(...)
from AlarmManager
, using the same PendingIntent
you used to set the alarm. Example:
this.getAlarmManager().cancel(mAlarmPendingIntent);
(this
refers to the Activity
or the Service
from which you are cancelling the alarm).
Here is the link for the API.
Create the PendingIntent as:
mAlarmPendingIntent = PendingIntent.getActivity(this, requestCode, intent, flags);
The API doc for PendingIntent is here.
精彩评论