Skip to content Skip to sidebar Skip to footer

Notification Custom Sound And Vibrate Not Working?

I have an app that receives notification, all is working. However, the custom sound and vibration is not working. I'm testing it on Android 9 pie. Uri sound = Uri.parse('android.re

Solution 1:

I am using MediaPlayer for custom sound. And This is Working fine for me. This is working for all devices.

private MediaPlayer player;

For play custom sound:

try {
       Uriuri= Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.siren);

       player = MediaPlayer.create(this, uri);
       player.setLooping(true); // This will play sound in repeatable mode.
       player.start();

//     mBuilder.setSound(uri);
     } catch (Exception e) {
        e.printStackTrace();
    }

For stop sound:

  if (player != null)
      player.stop();

This is working for me. Hope this will also helps you.

Post a Comment for "Notification Custom Sound And Vibrate Not Working?"