![](/img/trans.png)
[英]Android activity has one fragment ,I want to call another from this fragment , how can I achieve this
[英]FCM : I want to group all my notifications into one. How can I achieve this?
我已使用FCM接收通知。 当我收到多个通知时,它会填满通知状态栏。 如何将它们分组为一个?
我的代码:
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentTitle("ABC")
.setPriority(Notification.PRIORITY_HIGH)
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setGroup(GROUP_KEY_NOTIFICATIONS)
.setContentIntent(pendingIntent);
使用setGroup()无法正常工作。
编辑:
.setGroupSummary(true)
为OS棒棒糖工作,但不适用于棉花糖。 你能帮忙吗
若要对通知进行分组,必须在数据库中插入通知,并使用NotificationCompat.InboxStyle可以对通知进行分组。
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentTitle("ABC")
.setPriority(Notification.PRIORITY_HIGH)
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setGroup(GROUP_KEY_NOTIFICATIONS)
.setContentIntent(pendingIntent);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
for (int i = 0; i < data.size(); i++)
{
inboxStyle.addLine(data.get(i));
}
inboxStyle.addLine("");
notificationBuilder.setStyle(inboxStyle);
从包含所有通知的数据库中获取列表数据的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.