Ben*_*ris 12 android google-cloud-messaging
我正在我的应用程序中实现GCM并保持通知的散列以跟踪通知阴影中的内容(我必须根据用户是否进入应用程序来更改意图).
我为所有通知设置了deleteIntent PendingIntent.所有这一切都是从我的本地哈希中删除通知,因此它将不再更新.如果我清除所有内容或刷卡以删除通知,则意图被解雇.但是,我还将通知设置为自动取消.单击通知不会触发我的通知的deleteIntent.
我的问题是,当我的通知被自动取消时,有什么方法可以得到通知吗?
sva*_*tom 19
已报告此错误,但看起来它根本没有被调查过.解决这个问题就是我做的:
例如:
Notification.Builder builder = new Notification.Builder(context)
// Set other properties (not auto-cancel)
.setContentIntent(PendingIntent.getBroadcast(context, 0, new Intent(NOTIFICATION_CLICKED_ACTION), 0))
.setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(NOTIFICATION_DELETED_ACTION), 0));
notificationManager.notify(NOTIFICATION_ID, builder.build());
Run Code Online (Sandbox Code Playgroud)
if (intent.getAction().equals(NOTIFICATION_CLICKED_ACTION)) {
startActivity(new Intent(context, MyActivity.class));
notificationManager.cancel(NOTIFICATION_ID);
}
// Do deletion behaviour here (for both click and delete actions)
Run Code Online (Sandbox Code Playgroud)