Android notification setSound is not working

后端 未结 8 1623
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-01 04:46

In my hybrid Cordova Android app targeting API 23+ I want to use a custom sound for notifications. To that end I have done the following

  • In plugin.xml
8条回答
  •  醉酒成梦
    2021-02-01 05:00

    You are accessing the sound in a subfolder in the resources

    change the source of your uri to

    Uri uri = Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.siren);
    

    For the default sound, use:

    notification.defaults |= Notification.DEFAULT_SOUND;
    

提交回复
热议问题