我正在显示这样的通知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);
它不会取消通知,而只是关闭输入字段,并在我的通知下方附加文本,如下所示:
为什么这不取消通知?以及如何取消它。
更新:即使有带有通知的标签,结果也相同