Overwrite existing alarm

前端 未结 1 521
粉色の甜心
粉色の甜心 2021-01-18 20:25

I create an alaram in my app which is calling a BroadcastReceiver to setup notifications ever day with this code:

Intent intent = new Intent(Benachrichtigung         


        
相关标签:
1条回答
  • 2021-01-18 21:09

    To cancel or update an alarm using AlarmManager the Intent must match using the filterEquals. So basically, you re-create the PendingIntent the same as you did for the original and AlarmManager will see that they are the same. This includes the REQUEST_CODE, INTENT_ACTION, and INTENT_DATA (I may be missing something there but those are important.

    Note:

    EXTRAS are not used in comparing the two Intents.

    So if the two Intents are equal then the first will be overwritten. When I have more time I can try and find a resource to better explain that.

    According to the Intent Docs filterEquals

    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.

    0 讨论(0)
提交回复
热议问题