Custom notification sound not playing

后端 未结 1 1473
不知归路
不知归路 2021-02-08 17:25

I\'m trying to make a custom sound play on a status bar notification. The .mp3 file is in res/raw/. But when I notify the user the sound is not played. I\'ve t

相关标签:
1条回答
  • 2021-02-08 18:01

    From the documentation for ContentResolver:

    The Uri should be one of the following formats: android.resource://package_name/id_number

    You are passing the String "R.raw.notificationsound" which means nothing. Instead try this:

    notification.sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notificationsound );
    
    0 讨论(0)
提交回复
热议问题