Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 摘要通知触发声音效果_Android_Push Notification_Notifications_Android Notifications - Fatal编程技术网

Android 摘要通知触发声音效果

Android 摘要通知触发声音效果,android,push-notification,notifications,android-notifications,Android,Push Notification,Notifications,Android Notifications,出于测试目的,我将发送2个通知,并将它们与摘要通知捆绑在一起。 它可以工作,但会产生3种声音效果,这意味着有3种不同的通知到达。这是故意的行为吗 public void sendOnChannel1(View v) { String title1 = "Title 1"; String title2 = "Title 2"; String message1 = "Message 1"; String message2 = "Message 2"; Not

出于测试目的,我将发送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);
}
我想出来了。 为了避免摘要发出噪音,我们必须调用
.setGroupAlertBehavior(NotificationCompat.GROUP\u ALERT\u CHILDREN)