[英]Android notifications with multiple groups
我在我的應用中為通知實施了“直接回復”。 如何實施多個直接回復?
例如,如果用戶收到來自兩個不同人的消息,我希望他能夠通過通知回復他們中的每一個。
這是我的代碼:
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.