Android Oreo Does not Play Custom Sound for Notification
Finally I managed to find a solution on my own. Below is the code
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { if(notificationSoundUri != null){ // Changing Default mode of notification notificationCompatBuilder.setDefaults(Notification.DEFAULT_VIBRATE); // Creating an Audio Attribute AudioAttributes audioAttributes = new AudioAttributes.Builder() .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .setUsage(AudioAttributes.USAGE_ALARM) .build(); // Creating Channel NotificationChannel notificationChannel = new NotificationChannel(context.getString(R.string.channel_id_prayers),context.getString(R.string.channel_name_prayers),NotificationManager.IMPORTANCE_HIGH); notificationChannel.setSound(notificationSoundUri,audioAttributes); mNotificationManager.createNotificationChannel(notificationChannel); }}mNotificationManager.notify(0, notificationCompatBuilder.build());