B4A Library Notification Builder Library.

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User

Thank you.
As the first time I work with this, have you got a simple and complete example?
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
please can you help me? I copy the code from the b4a final app, but my app crash everytime
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
You need to show your code AND tell us the error please
This
B4X:
dim nb as notificationbuilder
nb.initialize
nb.SmallIcon = "icon"
nb.Ticker = "New Demo"
nb.Tag = "some tag"
nb.setActivity(Me)
nb.DefaultLight = True
nb.DefaultVibrate = True
nb.DefaultSound = True
nb.ContentTitle = "Titolo"
nb.ContentText = "testo"
nb.ContentInfo = "info"
nb.SubText = "soggetto "
nb.Notify(1)

on button_click event
 

Straker

Active Member
Licensed User
Longtime User
Can you please post also the error?
May be it could be something trivial... (Did you add the v4 support jar file as requested in the first post - under "how"?)
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
I solved. I declared and initialized the variable on Activity_create
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Sorry, I can't understand how to change icon notification
 

Straker

Active Member
Licensed User
Longtime User

barx

Well-Known Member
Licensed User
Longtime User
From Erel's post about services.
This is correct, the file should also be made read-only or it will be deleted when you compile.

Lastly the naming. if your file is called 'example.png'

then your code should be

B4X:
nb.SmallIcon = "example"

note, no 'png'
 

MattC

Member
Licensed User
Longtime User
I'm trying to display info without unlocking the phone. Is it possible to permanently display ticker text on the statusbar? Or call the notification repeatedly?

Or should I be trying this via another avenue?

Thanks
 

barx

Well-Known Member
Licensed User
Longtime User
I'm trying to display info without unlocking the phone. Is it possible to permanently display ticker text on the statusbar? Or call the notification repeatedly?

Or should I be trying this via another avenue?

Thanks


Unfortunately ticker text cannot be Persistent. I also believe that repeatedly calling the notification would affect the battery life of the device somewhat. Though this is only assumption, not proven fact.

What sort of info you looking at? If it just a couple of digits then you could possible look at a Level Icon. Any more than that though and it would either be display the info in the notification only or look at something like creating a widget or a app using Standout library.
 

MattC

Member
Licensed User
Longtime User
About 10 digits. Which is probably a lot I guess... I might try calling the notification once when the screen is turned on.
Thanks for your help
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Please, how can I set sound notification, if the file isn't in the final device?
 

barx

Well-Known Member
Licensed User
Longtime User
Please, how can I set sound notification, if the file isn't in the final device?
What do you mean that the sound isn't in the final device? you want to put the sound in your app apk?

If yes, add it to Assets (Files tab) then when your app starts first time, copy sound from assets to device, then use it from there.....
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Do you advise me, to create a dir of the app in the device, and copy inside the mp3 file?
 

barx

Well-Known Member
Licensed User
Longtime User
Yes, for example copy to file.DirInternal
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
So I copied the file to the RootExternal.
Is this code correct?

B4X:
nb.CustomSound = File.DirInternal & "/app/sound.mp3"

I passed the entire path of the mp3 file with the directory
 

Straker

Active Member
Licensed User
Longtime User
Do you advise me, to create a dir of the app in the device, and copy inside the mp3 file?
Yes, for example copy to file.DirInternal

What Barx is saying is that you place your file in the assets it will be included in the APK file and installed on the device. After the installation your file will be in the DirAssets folder, which is not a real folder but the assets compressed and stored in the APK. For this reason Barx suggests to copy the file from DirAssets to DirInternal (DirAssets has very slow access because is compressed, is good only for distribution).
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
I copied into File.DirRootExternal because I tried that if I set File.DirInternal there isn't the sound

B4X:
File.Copy(File.DirAssets, "sound.mp3", File.DirRootExternal & "/app", "sound.mp3")
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…