【发布时间】:2019-01-16 15:04:49
【问题描述】:
我正在显示带有RemoteInput 的通知,如下所示:
RemoteInput remoteInput = new RemoteInput.Builder("key_add_note")
.setLabel("add note")
.build();
PendingIntent AddNotePendingIntent =
PendingIntent.getBroadcast(getApplicationContext(),
(int) txn.get_id(),
new Intent(getApplicationContext(), AddNoteBroadcastReceiver.class)
.putExtra(Constants.IntentExtras.STA_TXN_ID, txn.get_id()),
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action action =
new NotificationCompat.Action.Builder(R.drawable.ic_action_edit_dark,
"add note", AddNotePendingIntent)
.addRemoteInput(remoteInput)
.build();
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationUtil.MISC_CHANNEL_ID)
.setContentTitle("TEST")
.setContentText("add Note")
.setSmallIcon(R.drawable.ic_action_edit_dark)
.setAutoCancel(true)
.addAction(action);
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(123456, builder.build());
输出:
点击添加注释,输入文本并提交后,我尝试取消通知,如下所示:
notificationManager.cancel(123456);
它不会取消通知,而只是关闭输入字段,并在我的通知下方附加文本,如下所示:
为什么这不会取消通知?以及如何取消。
更新:即使有带有通知的标签也会得到相同的结果
【问题讨论】:
-
如果这个特定的答案(类似问题)有效,请告诉我:stackoverflow.com/a/20007350/2710385
-
@dylan-myers 不,它没有。
-
有同样的问题,也使用自定义 int 标签(不是 1)。你解决过这个问题吗?
-
我在处理这个项目时无法解决它。
标签: android android-notifications remote-input