【问题标题】:Android 8.0 Double Notification SoundAndroid 8.0 双重通知声音
【发布时间】:2017-10-09 19:32:05
【问题描述】:

更新:我通过设置解决了它

            .setGroupAlertBehavior(GROUP_ALERT_SUMMARY)

我正在创建类似

的通知
new NotificationCompat.Builder(context, channel_id)
            .setColor(..)
            .setContentTitle(..)
            .setSubText(..)
            .setSmallIcon(..)
            .setAutoCancel(true)
            .setGroup(groupKey)
            .setGroupSummary(true)
            .setContentIntent(resultPendingIntent)
            .build();

在 8.0 上,某些设备会在每次通知时看到双重通知声音。 There is a blog post around this

某些应用似乎找到了解决问题的方法?救命!

【问题讨论】:

  • 你找到解决办法了吗

标签: android notifications android-8.0-oreo


【解决方案1】:

.setGroupAlertBehavior(GROUP_ALERT_SUMMARY)

【讨论】:

  • 仅在您为通知设置组时才有效(查看我的答案)
【解决方案2】:

由于android O中引入了新的“通知通道”,您需要创建通知通道并将NotificationManager.IMPORTANCE_LOW设置为它。

查看this

【讨论】:

  • 我不喜欢这个解决方案,因为它创建了一个额外的类别。我认为 .setGroupAlertBehavior(GROUP_ALERT_SUMMARY) 效果很好。
【解决方案3】:

您需要定义notifications Group。 然后,您需要设置 setGroupAlertBehavior,例如 @Anand Khinvasara 的回答

notificationBuilder.setGroup("com.YOUR_PACKAGE_ID.NOTIFICATIONS_GROUP");
notificationBuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-24
    • 2023-03-28
    • 2020-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多