How to show a notification without a sound java
To disable the sound in OREO 8.1, change the priority of the notification as LOW and it will disable the sound of notification:
NotificationManager.IMPORTANCE_LOW
The code is like:
NotificationChannel chan1 = new NotificationChannel("default", "default", NotificationManager.IMPORTANCE_LOW);
It works for me in Android Oreo.
You should just write your channel like this:
NotificationChannel notificationChannel = new NotificationChannel("Id" , "Name", NotificationManager.IMPORTANCE_DEFAULT); notificationChannel.setSound(null, null); notificationChannel.setShowBadge(false); notificationManager.createNotificationChannel(notificationChannel);
Remove the line to builder.setDefaults(Notification.DEFAULT_ALL);
. It will not play the sound, but you may need to enable all other notification defaults if preferred