【问题标题】:Android notifications with multiple groups具有多个组的 Android 通知
【发布时间】: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


【解决方案1】:

为手持设备创建多个通知时,您应该始终将类似的通知汇总到一个摘要通知中。

检查here 这显示了如何将多个通知构建为组。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多