出于测试目的,我发送了2个通知,并将它们与摘要通知捆绑在一起。
它可以工作,但会产生3种声音效果,意味着3种不同的通知到达。这是故意的行为吗?
public void sendOnChannel1(View v) {
String title1 = "Title 1";
String title2 = "Title 2";
String message1 = "Message 1";
String message2 = "Message 2";
Notification notification1 = new NotificationCompat.Builder(this, CHANNEL_1_ID)
.setSmallIcon(R.drawable.ic_one)
.setContentTitle(title1)
.setContentText(message1)
.setGroup("example_group")
.build();
Notification notification2 = new NotificationCompat.Builder(this, CHANNEL_1_ID)
.setSmallIcon(R.drawable.ic_one)
.setContentTitle(title2)
.setContentText(message2)
.setGroup("example_group")
.build();
Notification summaryNotification = new NotificationCompat.Builder(this, CHANNEL_1_ID)
.setSmallIcon(R.drawable.ic_one)
.setContentTitle("summary content title")
.setContentText("summary content text")
.setStyle(new NotificationCompat.InboxStyle()
.addLine(title2 + " " + message2)
.addLine(title1 + " " + message1)
.setBigContentTitle("2 new messages")
.setSummaryText("user@example.com"))
.setGroup("example_group")
.setGroupSummary(true)
.build();
notificationManager.notify(1, notification1);
notificationManager.notify(2, notification2);
notificationManager.notify(3, summaryNotification);
}