Skip to content Skip to sidebar Skip to footer

Android Disable Notification Sounds

I want to create a notification without any sounds. How can I do this? I tried the code below but it's not working for me: notification = mBuilder .setStyle(notiStyle)

Solution 1:

You can create the NotificationCompat.Builder object without using setSound(). This will create a notification without any sound.

notification = mBuilder
                .setStyle(notiStyle)
                .setSmallIcon(notificationIcon)
                .setTicker(title)
                .setWhen(0)
                .setAutoCancel(true)
                .setContentTitle(title)
                .setContentIntent(resultPendingIntent)
                .build();

Solution 2:

After your notification builder, add

notification.defaults = 0;

to tell the notification manager not to make any default values when not specified (eg. you set to null so it takes the default value, adding this will remove this behavior and so disable sounds completely).

Solution 3:

In Android 26+ (Oreo) you do this by setting notification channel importance level to 'IMPORTANCE_LOW' or below.

valimportance= NotificationManager.IMPORTANCE_LOW
valchannel= NotificationChannel(CHANNEL_ID, name, importance).apply {
    description = descriptionText
}

Post a Comment for "Android Disable Notification Sounds"