Uri sound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + \"://\" + context.getPackageName() + \"/\" + R.raw.notification_mp3);
mBuilder.setSound(s
Create a channel (I use this method in Application.clss
to create the channel )
public void initChannels(Context context) {
if (Build.VERSION.SDK_INT < 26) {
return;
}
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel("default"/*CHANNEL ID*/,
"CHANNEL_NAME",
NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription("Channel description");
assert notificationManager != null;
notificationManager.createNotificationChannel(channel);
}
And use this channel default
while creating instance of NotificationCompat
.... notificationBuilder = new NotificationCompat.Builder(this,"default") ....