06-21-2013 11:49 AM
Is is possible for an App to set its own notification sound by setting an Uri to a raw resource file in Notification.sound?
It does not seem to be working for me, perhaps there are some file permission declarations I need to do or somehow get the file to a shared directory?
Any help would be much appreciated, thank you.
Solved! Go to Solution.
07-08-2013 11:42 AM
Finally! Someone else with this issue.
I am having the exact same problem. I am trying to set the Notification.sound property using a raw URI.
notification.sound = Uri.parse("android.resource://" + getPackageName() + "/" + toneResourceID); notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
This works perfectly fine on all versions of Android but I get the default BB10 notification when I port the Android app over to BB10. I have tried a number of things and nothing seems to affect it.
Could it be that we need to set the Notification.sound property in a different, more compatible way? Anyone else seeing this on their converted Android app in BB10 or can confirm that this truly is a known issue??
07-08-2013 11:57 AM
I have a feeling this is a sandbox/permissions issue where audio file is not publically available for the Notification Center to play.
As a workaround, what I did was
1) Silence the Notification sound by not setting notification.sound
2) Play the audio file from the app using MediaPlayer. This happens asynchrously as I perform the notification.
Everything seems to happen in sync and looks right from the end user's point of view. Things may look off if there are multiple notifications happening at the same time but this is the best solution I could come up with for now.
07-08-2013 01:24 PM
Thanks! Your workaround mostly did the trick!
I had a similar idea and it did not work because I did not unset the Notification.sound property. Once I did that, it worked pretty well. Sometimes it cuts the sound off before it has a chance to play fully. Sometimes it will play 98% of it. I continue to investigate this issue. Please let me know if you have any ideas regarding this.
07-09-2013 11:59 AM