I am trying to add a custom sound to notification for API > 26. Below is the code
NotificationChannel notificationChannel = new NotificationChannel("channel id","channel name",NotificationManager.IMPORTANCE_HIGH);
mNotificationManager.createNotificationChannel(notificationChannel);
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.build();
notificationChannel.setSound(Uri.parse("android.resource://" + BuildConfig.APPLICATION_ID + "/raw/beep"),audioAttributes);
The problem here is that it, plays default piano sound of device rather than playing beep sound from assets. I am not allowed to use ringtone manager but common sense stats that notification sound should be that which is specified rather than default.
It works fine for API <= 26