B4A Library Custom Notification Library: Barx

Inman

Well-Known Member
Licensed User
Longtime User
I am starting to understand why the custom sound feature is not working when you try it with some of the native sound files like ringtones. The AHPreferenceActivity returns the URI of the ringtone like this:

content://media/internal/audio/media/31

But that is just the URI and NOT the path. Even if you change content:// to file:///, it still won't give you the actual path in the internal system, which is file:///system/media/audio/notifications/Beat_Box_Android.ogg

I was looking for a code to convert URI to it's real path and found this reply by Erel

http://www.b4x.com/forum/basic4andr...orials/13473-uri-content-media-real-file.html

So now I am getting the correct path file:///system/media/audio/notifications/Beat_Box_Android.ogg. But unfortunately SetCustomSound is still not working even with the correct path. I wonder why.

As for adding customsound routine to advancednotification, I am ok with using customnotification. I like the extra features and might explore custom layouts in the future.
 

barx

Well-Known Member
Licensed User
Longtime User
Ok, take a look Here. Scroll down to the adding a sound section. Are you accessing the media with an intent like the 'MediaStore' example in that section. The CustomSound Method uses uri.parse (like the first example in that section). Also try making the
B4X:
cn.DefaultSound = false

Didn't get time to finish the mods to the lib last night, very nearly done though and will be uploaded later when I get home from work.

thanks
 

Inman

Well-Known Member
Licensed User
Longtime User
Ah yes. Setting DefaultSound = False did the trick. It works even with the content:// URI itself, without the need to convert to it's file:// path.
 

barx

Well-Known Member
Licensed User
Longtime User
Ah yes. Setting DefaultSound = False did the trick. It works even with the content:// URI itself, without the need to convert to it's file:// path.

Brilliant, I've also update the lib. Re-download from 1st post.

Hopefully should sort it out. Unfortunately not had time to test. Let me know how you get on with it. thanks.

Guess i better make Advance Notification official when i get a minute. Didn't realise anybody was using it...
 

Inman

Well-Known Member
Licensed User
Longtime User
Tested layout 1 and now it shows the correct notification icon. Thanks man.

And yes, you should make Advance Notification official, if possible with CustomSound as well. Will be incredibly useful for users who are looking for just the basic layout + added features.
 
Last edited:

Inman

Well-Known Member
Licensed User
Longtime User
I just noticed that custom notification doesn't show the time of notification on the right side, as in phone's default notification. Since the previous version of my app already has that (from Advanced Notification library), I think the users will notice the missing time stamp.

So, could you please update Advanced Notification library with SetCustomSound?

Or is it possible to add another layout to Custom Notification, which basically adds time stamp to the left of layout 1?
 
Last edited:

barx

Well-Known Member
Licensed User
Longtime User
You can add youe own xml layouts and add the required data fields. The presets are there for example and can be editted as required.

But I think you best option would be the advanced lib which I will update and release when I can. Currently on vacation so not getting much computer time. Will try to get it done in next 24 hrs. Thanks

Sent from my HTC Desire Z
 

Inman

Well-Known Member
Licensed User
Longtime User
Thanks man. Sorry I didn't know you were on vacation. I will wait for your update.
 

barx

Well-Known Member
Licensed User
Longtime User
No worries Inman, needed an excuse to get laptop out anyway.

Take a look here

For obvious reasons I have not tested 100% but all I have done is add documentation and copy some methods from the Custom Notification Library.
 

Inman

Well-Known Member
Licensed User
Longtime User
Thanks man. New library works perfectly, with CustomSound too.

Enjoy your vacation
 

barx

Well-Known Member
Licensed User
Longtime User
Glad to hear it. Cheers mate.

By all means still post any issues. I may just take longer to reply

Sent from my HTC Desire Z
 

walterf25

Expert
Licensed User
Longtime User
Error Help

Hello all, i need some help, i have been implementing the custom notifications library for quite some time on one of my apps, i have been receiving some errors from some customers, i'm trying to debug what the problem is but can not figure it out.

this is the error i get from the logs:


I just updated this library to 1.1 and it still gives me the same error, i have all the xml files where they belong but still get same error,

hope anyone can help me figure out why i get this error, and hopefully how to resolve it.

Thanks guys!
 

barx

Well-Known Member
Licensed User
Longtime User

Walter, any chance you can post your notification code or pm it me, thx
 

Inman

Well-Known Member
Licensed User
Longtime User
I am starting to learn custom XML layouts. I see that I can set a custom layout for notification the library. I have two doubts.

Which all views are allowed in the notification bar custom layout?

Is it possible to design a music player control like notification, like in the bottom part of the screenshot?

 

melamoud

Active Member
Licensed User
Longtime User
using the lib as part of a service

hi,

I'm trying to use the lib as part of a service, but when I Do
Dim n As CustomNotification in the Process_Globals section
I get a compliation error
B4X:
Compiling code.                         Error
Error compiling program.
Error description: Cannot access activity object from sub Process_Globals.
Occurred on line: 16
Dim n As CustomNotification' the notification var that notify the user on the connectivity
Word: customnotification

is this a limitation or am I doing something wrong (it was working with the standard notification object

thanks
 

barx

Well-Known Member
Licensed User
Longtime User
Cannot say i've tried in it in Process_Globals. Whenever I use it in service I declare in Service_Start.
 

melamoud

Active Member
Licensed User
Longtime User
in servcie

Can you try and see if that can be fixed ?
defining it in the servcie_start is not going to work for me, since I need to keep it global, have the UI access it (to update the attricbutes)

thanks
 

basicall

Member
Licensed User
Longtime User
:sign0098: I have tested the lib. It could work well with my moto.

Sir, could you add a property to this lib for setting LED indicator color ? For example if battery in low power status we need to flash with red color but not green color ?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…