【发布时间】:2017-01-19 14:16:54
【问题描述】:
我为我的应用中的通知实现了“直接回复”。 如何实现多个直接回复?
例如,如果用户收到来自两个不同人的消息,我希望他能够通过通知回复每个人。
这是我的代码:
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());
【问题讨论】:
-
检查here 这显示了如何构建多个通知。
标签: android push-notification notifications android-notifications