I am trying to develop 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()onAlarmManagerwith an equivalentPendingIntentto the one you used to register the alarm in the first place. By “equivalent” I mean that it is the same type ofPendingIntent(activity, service, broadcast) and wraps anIntentthat is the same on all routing elements (component, data, MIME type, categories).