Android Notification Channel Sounds Stop Working When Using Sound Uris That Reference Resource Ids
Solution 1:
It seems like this issue setting the soundUri
as follows:
valsoundUri= Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
context.applicationContext.packageName + "/" + R.raw.notification)
It looks like the value of R.raw.notification
changed from 2131689979
(version where sound works) to 2131755515
(version where sound doesn't work). And since you can't change your notification sound with Notification Channels, I am almost certain that the channel is trying to resolve the soundUri
with the old resource id (android.resource://our.package.name/2131689979
).
I think the better approach is to reference the file directly by name as follows:
valsoundUri= Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
context.applicationContext.packageName + "/raw/notification")
I also notice apps like Facebook Messenger and Slack use a public Notifications folder where they probably just copy the file over and reference that exact path. This also seems to allow the user to re-select the app-provided sound because it is visible in the filesystem.
Post a Comment for "Android Notification Channel Sounds Stop Working When Using Sound Uris That Reference Resource Ids"