Проблема: я просто всегда получал последний идентификатор уведомления при ответе на уведомление, он обновляет последнее созданное уведомление, даже если я отвечаю первым или другим, чем последнее созданное уведомление.
Итак, когда я обновляю notif_1, я получаю обновленное notif_4 (последнее уведомление)
Итак, когда я обновляю notif_2, я получаю обновленное notif_4 (последнее уведомление)
То, что я хочу, это когда я отвечаю на notif_1, чтобы обновить notif_1 не от другого уведомления
public static void setAndUpdateNotificationMessage(Context context, CharSequence[] history, CharSequence message, CharSequence title) {
String replyLabel = ("Your message here...");
RemoteInput remoteInput = new RemoteInput.Builder(KEY_TEXT_REPLY)
.setLabel(replyLabel)
.build();
Intent replyIntent = new Intent(context, NotificationBroadcastReceiver.class);
// replyIntent.putExtra(KEY_MESSAGE_ID, 1);
replyIntent.setAction(REPLY_ACTION);
replyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent replyPendingIntent =
PendingIntent.getBroadcast(context,
requestCode,
replyIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action action =
new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon,
("Reply"), replyPendingIntent)
.addRemoteInput(remoteInput)
/*for wear watch notification*/
.setAllowGeneratedReplies(true)
/*for wear watch notification*/
.build();
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_stat_name)
.setContentTitle(title)
.setContentText(message)
.addAction(action)
.setGroup(GROUP_KEY_WORK_EMAIL)
.setPriority(Notification.PRIORITY_DEFAULT);
if(history != null) {
builder.setRemoteInputHistory(history);
}
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(id, builder.build());