开发者

Activity to trigger and cancel a AlarmManager

I am trying to devel开发者_Go百科op an app where it locks down the Activity and starts a service which will set an AlarmManager to setRepeating() trigger to another Service which will send a SMS containing the phone's location.

I have achieved the periodic sending of the SMS. However, I now want to cancel the AlarmManager when I finish() the lockdown activity. Please help me as I cant seem to understand the approach to address this.

Program flow: Lockscreen (Activity trigger Service) --> AlarmManager (in Service class) --> Coordinate (Another Service that send sms)


Call cancel() on AlarmManager with an equivalent PendingIntent to the one you used to register the alarm in the first place. By "equivalent" I mean that it is the same type of PendingIntent (activity, service, broadcast) and wraps an Intent that is the same on all routing elements (component, data, MIME type, categories).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜