NotificationCompat.PRIORITY_DEFAULT doesn't make sound on older OS versions

懵懂的女人 提交于 2020-01-06 07:05:10

问题


I don't specify any sound (resource), I want to use the default sound

It works fine on Android 8 and 9

But on Android 4-7 it triggers notification without sound

How can I make the same behavior on all Android?

Notificaiton builder:

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:


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



来源:https://stackoverflow.com/questions/56407328/notificationcompat-priority-default-doesnt-make-sound-on-older-os-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!