In my Android 23+ Android-based hybrid app, I want to use customizable sound for notifications. For this, I did the following
- In the file
plugin.xmlfor the individual custom plugin that I use in the application, I declare <resource-file src="src/android/res/unysound.mp3" target="res/raw/mysound.mp3" />'.
Opening APK as a zip archive. I see that the mp3 file actually ended up in `res / raw / mysound.mp3 '. - When creating a notification, I do the following
Notification notification = new Notification.Builder(context)
.setDefaults(0) //turns off ALL defaults
.setVibrate(vibrate) /sets to vibrate
....
.setSound(uri).build();
Where
Uri uri = Uri.parse("android.resource://" + ctxt.getPackageName() + "/raw/mysound.mp3");
This, apparently, is the recipe indicated in a number of articles that I find in the place of searching on Google and even in other threads on SO. And yet, when I issue a notification, I do not hear the expected sound. What can i do wrong?
, Cordova , APK, class R not known/found...