Custom notification sound , android Oreo?

android oreo notification example
turn off notifications sound android programmatically
notification icon not showing android oreo
android notification category
notification helper android
android remove notification channel
android push notification custom sound
android studio notification sound not working

I want to set a custom notification sound from a raw mp3 or wav file in my app. Below is my code

private void sendMyNotification(String message) {
    Intent intent;
    if (sharedPreferences.getBoolean(SPConstants.IS_LOGGED_IN, false)) {
        intent = new Intent(this, ActivityNotification.class);
    } else {
        intent = new Intent(this, ActivitySplash.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
    Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    soundUri = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/" + R.raw.panic);
    AudioManager manager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
    manager.setStreamVolume(AudioManager.STREAM_MUSIC, 100, 0);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_HIGH);

The panic audio file resides in res->raw. I have tried to use both mp3 and wav formats of the sound but nothing seems to work to set the notification sound. I am currently testing on Pixel 2 OS 8.1.

Any suggestions what could be the issue?

Custom notification sound , android Oreo?, For Oreo and up, the sound and vibrate settings can no longer be set from within the PagerDuty app; they must be set inside the Settings app on a  This is especially true on Android where Google only recently solidified its standards for application architecture and are still refining features like permissions, split-screen, and Do Not Disturb. The Mobile team at PagerDuty was put in a sticky situation from one such change: the introduction of notification channels with Android Oreo.

Simple answer:

Uri soundUri = Uri.parse(
                         "android.resource://" + 
                         getApplicationContext().getPackageName() +
                         "/" + 

AudioAttributes audioAttributes = new AudioAttributes.Builder()

// Creating Channel
NotificationChannel channel = new NotificationChannel("YOUR_CHANNEL_ID",
channel.setSound(soundUri, audioAttributes);

((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE))

Custom Notification Sounds for Android Oreo and Beyond, This example demonstrate about Custom Notification Sounds for Android Oreo and BeyondStep 1 − Create a new project in Android Studio,  Custom notification sound , android Oreo? Ask Question I want to set a custom notification sound from a raw mp3 or wav file in my app. Below is my code.

Late but might be helpful to some one, just add below line in your NotificationCompat.Builder() instance:

.setSound("your sound uri",AudioManager.STREAM_NOTIFICATION)

Note: As NotificationCompat.Builder() is backward compatible , so AudioAttributes etc in notification channel is not required

Custom Notification Sounds for Android Oreo and Beyond?, A custom text message tone can tell us to respond to one notification among the newer notification protocols implemented with Android Oreo. RELATED: How to Use Android Oreo's New Notification Channels for Ultra-Granular Notification Customization. Converbration (horrible name, great app) hails itself as “intelligent notifications,” because it takes the notification system to a whole new level of customization (at least, for text messages).

How to set custom text tones for your contacts on Android, I just replaced my dying Samsung Galaxy S6 with a shiny new S9 which runs Android Oreo. While I've set the notification sound in the  How to get custom/different SMS notification tone per contact (download the new app now) especially if its major one like the Android 8.0 Oreo. Tap on Notification Sound to select the

Can't set custom notification sound (Android Oreo), Change default Android notification sound; Change WhatsApp notification tones With Android 8.0 (Oreo), the method is also identical. In Android Oreo you can no longer set the priority level for individual notifications. Instead, you need to specify the channel’s importance level, which is then applied to every notification

How to change the notification sound on your Android phone , It's also fun to create custom sounds for Android notifications, so you Instructions in this article apply to Android 10, 9.0 (Pie), and 8.0 (Oreo). Add Custom Notification Sounds on Android Though adding a notification sound using PC is straight-forward, however, things get little tricky when you are not in a mood to use a PC. Different File Manager apps have different settings and options.