Reputation: 1055
I am trying to cancel an alarm that was set last time my app was run. This alarm has a PendingIntent that was set with PendingIntent.getBroadcast
and an inner Intent that contains some variables set by intent.putExtra
. My question is this, I know that alarms can be canceled by calling alarmManager.cancel(pendingIntent)
where pendingIntent is the same as the one used to set the alarm. But, if the variables placed into the intent are changed will the alarm still be canceled? For example, I set an alarm with intent.putExtra("Joe") where Joe is a contact name. Later my app is closed and when it is re-run I try and cancel the alarm for "Joe" but the user has changed the name of the contact to "Jones". Can I cancel the alarm without knowing the variables I put into the intent?
Thanks!
Upvotes: 0
Views: 83
Reputation: 74
According to this question (which references the documentation), anything you add using putExtra
is not taken into account when checking if an intent is equal to another one.
It shouldn't matter if the extra data is changed.
Upvotes: 1
Reputation: 9125
I think it should cancel the alaram anyway, even though some data is different. The cancel
method says:
Any alarm, of any type, whose Intent matches this one (as defined by filterEquals(Intent)), will be canceled.
And filterEquals
says:
Determine if two intents are the same for the purposes of intent resolution (filtering). That is, if their action, data, type, class, and categories are the same. This does not compare any extra data included in the intents.
Anyhow, I'd still test it myself.
Upvotes: 1