开发者

How can I remove alarm when user delete event?

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.

  1. When I delete event from my schedule.
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜