user1256477
user1256477

Reputation: 11191

notification add my own sound

I'm adding a notificationCompat to my app, it works fine, but now I would like to add my own sound to the notification, so, I read that is:

.setSound(Uri sound);

But, I cant get the uri, how should I do this? where should the .wav file in my project?

Upvotes: 0

Views: 144

Answers (1)

Dhruvil Patel
Dhruvil Patel

Reputation: 2930

To add your own notiffication sound follow this step. edit in your service class.

PendingIntent pendingIntent= PendingIntent.getActivity(getBaseContext(),0, myIntent,Intent.FLAG_ACTIVITY_NEW_TASK);
                // myNotification.defaults |= Notification.DEFAULT_SOUND;
                 myNotification.sound = Uri.parse("android.resource://com.adroid.alarm"+R.raw.airtel_latest);

Put sound file in raw folder. Edit com.adroid.alarm with your package name.

Upvotes: 2

Related Questions