How to set notification with custom sound in android

前端 未结 6 1886

I copied the mp3 (kalimba.mp3) file into the raw folder in the res folder. But when the notification is triggered it produces the default sound.

6条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 03:09

    notification.sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notifysnd);
    notification.defaults = Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE;
    

    if defined DEFAULT_SOUND, then the default sound overrides any sound

提交回复
热议问题