How to set notification with custom sound in android

前端 未结 6 1891

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:15

    R.raw.kalimba is an integer resource ID; you want the name of the sound resource in that Uri. So try:

    notification.sound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE
            + "://" + getPackageName() + "/raw/kalimba");
    

提交回复
热议问题