Cancelling a PendingIntent

前端 未结 1 907
执念已碎
执念已碎 2020-12-01 08:24

When using a PendingIntent in an AppWidgetProvider, I\'m using the following code:

views.setOnClickPendingIntent( viewId,
                Pendin         


        
相关标签:
1条回答
  • 2020-12-01 08:43

    Where you want to cancel it, you would do the following (somewhere else in your code base):

    PendingIntent.getBroadcast(context, 0, intent, 
                               PendingIntent.FLAG_UPDATE_CURRENT).cancel();
    

    where intent is the same one as referenced in your code above. PendingIntent.getBroadcast(...) using the PendingIntent.FLAG_UPDATE_CURRENT will return a reference to the existing one already created, or create one if it doesn't currently exist.

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