Android Notification Sound
Just put your sound file in the Res\raw\siren.mp3
folder, then use this code:
For Custom Sound:
Notification notification = builder.build();
notification.sound = Uri.parse("android.resource://"
+ context.getPackageName() + "/" + R.raw.siren);
For Default Sound:
notification.defaults |= Notification.DEFAULT_SOUND;
For Custom Vibrate:
long[] vibrate = { 0, 100, 200, 300 };
notification.vibrate = vibrate;
For Default Vibrate:
notification.defaults |= Notification.DEFAULT_VIBRATE;
Another way for the default sound
builder.setDefaults(Notification.DEFAULT_SOUND);
What was missing from my previous code:
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
builder.setSound(alarmSound);