Ad

NotificationCompat.PRIORITY_DEFAULT Doesn't Make Sound On Older OS Versions

- 1 answer

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)
Ad

Answer

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

Ad
source: stackoverflow.com
Ad