1

Я внедрил «Прямой ответ» для уведомлений в своем приложении. Как реализовать несколько прямых ответов?Уведомления на Android с несколькими группами

Например, если пользователь получает сообщения от двух разных людей, я хочу, чтобы он мог ответить каждому из них через уведомление.

Вот мой код:

notificationBuilder.setContentTitle(title) 
        .setContentText(text); 
NotificationCompat.InboxStyle expandedStyle = new NotificationCompat.InboxStyle(); 
expandedStyle.setBigContentTitle(title); 
for (String key : mMessageList.keySet()) { 
    for (String message : mMessageList.get(key)) { 
     expandedStyle.addLine(message); 
    } 
} 
expandedStyle.setSummaryText(summary); 
notificationBuilder.setStyle(expandedStyle); 

String replyLabel = context.getString(R.string.reply_to, name); 
RemoteInput remoteInput = new RemoteInput.Builder(KEY_TEXT_REPLY) 
       .setLabel(replyLabel) 
       .build(); 

NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(
       R.drawable.reply, replyLabel, getReplyPendingIntent(context)) 
       .addRemoteInput(remoteInput) 
       .build(); 

notificationBuilder.addAction(replyAction); 

NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
nm.notify(NOTIFICATION_ID, notificationBuilder.build()); 
+0

Проверить [здесь] (https://stackoverflow.com/questions/37539297/how-to-display-multiple-notification-as-a-group) показывает, как создавать несколько уведомлений. –

ответ

0

При создании нескольких уведомлений для портативного устройства, вы всегда должны объединять подобные уведомления в одном кратком уведомлении.

Check here показывает, как создать несколько уведомлений в виде групп.