How to set notification with custom sound in android

前端 未结 6 1889

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

    Try this:

    Uri sound = Uri.parse("android.resource://" + context.getPackageName() + "/raw/notifysnd);
    notification.setSound(sound);
    

提交回复
热议问题