On the system, notifications are muted for my app. How do I allow my app to play sound for notifications by default?It's on all phones
Asked
Active
Viewed 73 times
0
-
Have you checked this [SO](https://stackoverflow.com/questions/15809399/android-notification-sound) and the [documentation](https://developer.android.com/training/notify-user/build-notification)? – David Lee Jul 02 '21 at 08:28
2 Answers
0
Normally the following code controls the notification sound
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, "name", NotificationManager.IMPORTANCE_LOW);
Low importance means notifications are muted. High importance notifications notify the user.
But if the Android System disables the sound for an application, you might not be able to play sound for the notification.

Joachim Sauer
- 302,674
- 57
- 556
- 614

Eishon
- 1,274
- 1
- 9
- 17
0
On pre Oreo devices, you can enable the notification sound by making the priority high
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setPriority(NotificationCompat.PRIORITY_HIGH) // Set priority to PRIORITY_HIGH to enable notification sound
.setContentIntent(pendingIntent)
.setAutoCancel(true);
On Oreo and above devices, you must create a channel for the notification
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Set importance to IMPORTANCE_HIGH to enable notification sound on Android 8.0 and above
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, "channel name", NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(channel);
}

hientp
- 634
- 4
- 11