Issue with cancelling the AlarmManager - PendingIntent

后端 未结 5 1834
轻奢々
轻奢々 2020-12-19 01:49

I have an app which reminds people to do their tasks. So there is one PendingIntent, now the user can delete the alarm when he wants to. In this code, there is just one Pend

5条回答
  •  暖寄归人
    2020-12-19 02:47

    According to the Android documentation, in order to stop an alarm, you should create an Intent with the same data, but not necessarily the same extras:

    public void cancel (PendingIntent operation)

    Remove any alarms with a matching Intent. Any alarm, of any type, whose Intent matches this > one (as defined by filterEquals(Intent)), will be canceled.

    filterEquals(Intent)

    public boolean filterEquals (Intent other)

    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.

提交回复
热议问题