Android Question Barx Notifications Builder and Set Custom Sound

Marcos Alves

Well-Known Member
Licensed User
Longtime User
I'm using the @barx notifications builder and, in Android &, couldn't set a custom sound anymore due the android.os.FileUriExposedException.

B4X:
cn.CustomSound = "file:///sdcard/notification/ringer.mp3"

Some recommended to user this : https://www.b4x.com/android/forum/t...om-your-app-with-file-provider.70458/#content

But I don't think that will be useful in this case because it's a notification and is called from a service... I Manifest it's recommended to reference an Activity to enable uri... I also don't want to replace @barx notifications those work fine in all Android versions.
I think that this could be a problem to this lib and the developer can help us to fix.

Any suggestion?
 

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Same suggestion that I gave you in the other thread you made. You should use NB6. At least for Android 8+ devices.
Then... I'll need to check: IF version =7+ (7 doesn't work also), use NB6, else, use Notifications Builder... it looks a little bit complex to fix a problem that should be simple... two notifications library in app... check...
What do you think about this ? -> https://stackoverflow.com/questions...tion-file-storage-emulated-0-test-txt-exposed

I'll try to implement this solution. Is it possible?
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
NB6 is a class written in B4A. You can see in the code how it creates notifications with custom sound.

I'm not sure that barx library properly handles the channels. My last suggestion about this is to use NB6 for Android 8+ devices (or less).
Hi @Erel . After testing NB6 I noticed that in Android 5x the notifications are broken - doesn't matter what type you choose, there is always a simple notification. I think that it's a problem of the class because in the same device (physical) I tested the old notifications builder from @barx and it runs perfectly (except the customsound problem, which I already changed the "file://" reference to "content://" reference getting the uri of the file, and doesn't work).

In Android 6+ NB6 runs perfectly... but I can't take the risk to do incorrect notifications to my app users: each image and/or sound corresponds to some specific event, more or less important... then, I have the options:

1. Try to make Nb6 run on Android 5x (there are still a lot of devices here using Android 5... )
2. Use Notifications Builder and replace custom sound by a played sound by mediaplayer (with this option I will loose the relation of the volume level of the notification with silence user controls... lets see.)
3. Try to fix old notifications builder from @barx to run with uri (should run but isn't now... need to debug)

I really would like to use NB6 but with Android 5.x limitations I'll loose a big number of customers here... could u help me?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Hi @Erel . As always, thanks for answering. First, I would like that you knew that it's an honor to have my questions answered by you. I'm a developer also and as a developer I understand your time limitations and the fact that, as the creator of a so important product like B4X, you can't loose your time repeating things that you already published. But besides what my posts could appearance at the first time, I always use to do an extensive research before questioning something - including outside B4A community. I use B4A in my company - a 25 years old technology company in Brazil - I'm a programmer since 80's, and I am the main enthusiast of B4A here in the enterprise.
In every situation I'm focused mainly in RAD and commercial effects of technical details - that's why I'm not now a simple programmer inside a department in a generic enterprise, but an entrepreneur, like you. In the specific NB6 situation, it's indubitably a indispensable lib and the opportunity to make it running for at least Android 5+ is clearly an important feature - it's possible as the old barx lib runs almost with all resources (but with customsound problems in SDK 26 and Android 7+).
If I could add the same approach that make barx lib runs in 5x mixed with NB6 evolution will be great. I think that maybe - only maybe - could be easy for you, as you are the Android specialist (I'm a telecommunications specialist), but my evaluation about how this could be easy maybe is wrong... I don't know.
Whatever... sorry for the extensive text, but I really needed to talk. - like I told, as a "veteran programmer" it's an honor to be heard by you and get you answers. Be comfortable if you want to give a feedback - I'm here.

Thanks!
 
Upvote 0
Top