NotificationCompat.PRIORITY_DEFAULT在较旧的OS版本上不发出声音

时间:2019-06-01 13:49:20

标签: android android-notifications

我没有指定任何声音(资源),我想使用默认声音

在Android 8和9上运行正常

但是在Android 4-7上,它会触发没有声音的通知

如何在所有Android设备上进行相同的行为?

通知生成器:

NotificationCompat.Builder(this, channelId)
    .setSmallIcon(R.drawable.notify_icon
    .setContentTitle(title)
    .setContentText(subtitle)
    .setPriority(if (Prefs.isNotificationSound) NotificationCompat.PRIORITY_DEFAULT else NotificationCompat.PRIORITY_LOW)
    .setCategory(NotificationCompat.CATEGORY_PROMO)
    .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
    .setAutoCancel(true)

1 个答案:

答案 0 :(得分:1)

Have you tried to use .setDefaults(Notification.DEFAULT_SOUND) ?

相关问题