[英]Android notifications with multiple groups
I implemented "Direct Reply" for the notifications in my app. 我在我的应用中为通知实施了“直接回复”。 How do I implement multiple direct replies?
如何实施多个直接回复?
For example, if the user receives messages from two different people, I want him to be able to reply to each one of them through the notification. 例如,如果用户收到来自两个不同人的消息,我希望他能够通过通知回复他们中的每一个。
Here is my code: 这是我的代码:
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());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.