Rog*_*pid 14 android android-pendingintent
在a中使用PendingIntent时AppWidgetProvider,我使用以下代码:
views.setOnClickPendingIntent( viewId,
PendingIntent.getBroadcast( context, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT ) );
Run Code Online (Sandbox Code Playgroud)
所以目前没有对getBroadcast方法返回的PendingIntent的引用.在特定情况下,我现在想要取消PendingIntent.有没有办法从视图中获取PendingIntent?或者是之后通过保持对它的引用来调用PendingIntent的cancel方法的唯一方法?
Chr*_*ght 30
如果要取消它,可以执行以下操作(代码库中的其他位置):
PendingIntent.getBroadcast(context, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT).cancel();
Run Code Online (Sandbox Code Playgroud)
哪个intent与上面代码中引用的相同.PendingIntent.getBroadcast(...)使用the PendingIntent.FLAG_UPDATE_CURRENT将返回对已创建的现有引用的引用,或者如果当前不存在则创建一个引用.
| 归档时间: |
|
| 查看次数: |
17396 次 |
| 最近记录: |