B4A Library Notification Builder Library.

Discussion in 'Additional libraries, classes and official updates' started by barx, Mar 17, 2013.

  1. Dave O

    Dave O Active Member Licensed User

    The constants are not yet included in this library, but according to the Android docs, the values range from -2 (minimum) to +2 (max).
    Last edited: Jun 20, 2016
  2. ilan

    ilan Expert Licensed User


    when i try to create a notification with 2 buttons FROM a service (nb.AddAction2...) that will call another service on click, the buttons are not displayed.
    if i create the notification from an activity the buttons are displayed.

    is it not possible to create a notification from a service that includes buttons? or am i doing something wrong?

    Dim nb As NotificationBuilder
    Dim nbBigTextStyle As NotificationBigTextStyle
                        nb.SmallIcon = 
                        nb.Ticker = 
                        nb.ContentTitle = 
                        nb.DefaultSound = 
                        nb.DefaultVibrate = 
                        nb.ContentText = 
                        nb.ContentInfo = 
                        nb.SubText = 
                        nb.OnGoingEvent = 
    '                    nb.AddAction2("recicon","Stop","Tag1",nbservice)
    '                    nbBigTextStyle.BigContentTitle = "Recording#####..."

  3. Dave O

    Dave O Active Member Licensed User

    Hi @barx , thanks for this great library, which made it easy to create my latest app (I.C.E. Lock).

    I've sent you a small donation as thanks. :)
    Last edited: Sep 11, 2017
    barx likes this.
  4. Dave O

    Dave O Active Member Licensed User

    I did notice one issue while developing my app. It shows a ongoing notification at startup (using the Starter service). When you tap the notification, it launches the main activity.

    This all works fine, except if I reboot. Then, this happens:
    - The device restarts.
    - The notification appears about 10 seconds later. (I assume it's busy doing other things first, and my notification priority is -1, so maybe it gets done last. No worries anyway.)
    - Here's the problem - when I tap the notification (after reboot), it launches the activity, but the activity appears blank - just a white screen.
    - If I rotate the device (or tap the notification again), it repaints the activity normally.

    I can post code if that helps. Any thoughts?
  5. MohammadNew

    MohammadNew Active Member Licensed User

    this library can display notifacation when app. is not working? such as I select spcific time then display it.
  6. Dave O

    Dave O Active Member Licensed User

    Yes, you should be able to run a service in the background that posts a notification at a certain time, even if the app is not running.

    I searched the forums on "schedule notification" and got these results.
  7. DonManfred

    DonManfred Expert Licensed User

    i´m not familar with this lib. But maybe you need an activitycontext to see buttons. Maybe you need to call a sub from your service in your activity (callsubdelayed) to send the notification from an activity....
  8. ilan

    ilan Expert Licensed User

    ok i found the reason for that behavior, if you have more then 1 notification then the notification is not extended and you dont see the buttons but you can slide it down and then you see them. if you got only 1 noti it is shown extended and you see the buttons.
    DonManfred likes this.
  9. barx

    barx Well-Known Member Licensed User

    Tell me as much info as you can Dave and I will see if anything springs to mind. Or even better, re-create in a test project and send the project to me.
  10. ilan

    ilan Expert Licensed User

    hi @barx is it possible to show the notification already opened on a biglayout style?
    when i have more then 1 notifications i dont see the buttons in my notification so i need to slide it down to see them
    is it possible to have the noti already opened when it is created?

  11. barx

    barx Well-Known Member Licensed User

    I have searched in the past for info ond oing this and not found anything conclusive. The best effort is setting the priority to 2 (int) which equates to PRIORITY_MAX.

    Other than that, the only way I can think is to play with the different custom layouts.

    If you can find some info on the web for how to acomplish it in java, I can tell you how to do it in B4A.
    ilan likes this.
  12. Dave O

    Dave O Active Member Licensed User

    Good idea. Attached is a minimal project that shows the bug:
    - Compile the app onto your phone (in release mode), run it the first time to activate the notification, then reboot your phone.
    - After reboot, the notification will appear (may take some time - about 10 seconds on my phone).
    - Pull down to see the notification and tap it to launch the main activity.
    - The activity appears blank, but if I rotate the phone, it repaints properly.

    Tested on a Samsung Note 3 (Android 5.0) and Nexus 7 (Android 5.1.1)

    Any help appreciated!

    Attached Files:

  13. barx

    barx Well-Known Member Licensed User

    @Dave O I had to do some fiddling about to get the project running:
    Update B4A (it was complaining and I thought it may have been causing the other issues I was having)
    The project couldn't find mainContent.bal, which wasn't there but I couldn't get the project to forget it
    Then because the project wasn't loading the above layout, it complained that variables weren't initialized
    ... blah ... blah ... blah, lol
    Anyways, finally got it running and I saw the same issue as you. I added a ton of looging points to see what order things were happening (if at all). The order of things when starting from boot look squiffy. I'm not sure entirely how the Starter service works because I haven't done any new to use it but I thought it may be at the cause.

    I created a new service, Set the Starter service to NOT start on boot, set the new service TO start on boot and called the notifcation from the new services' Service_Start method.

    Seems to work ok here now, Try it your end and let me know.

  14. mw71

    mw71 Active Member Licensed User


    i use a Code Module to Show the notification:
    Sub Process_Globals
    Dim Titel_Big As String
    Dim Titel_Short As String
    Dim Text_Big As String
    Dim Text_Short As String
    Dim Number As Byte

    End Sub

    Sub NotiBuilder
    'SetStyle (BigTextStyle) braucht Api 16+
    Dim p As Phone
    Dim SDK As Byte

    If Titel_Big ="" Then Titel_Big = Titel_Short
    If Titel_Short="" Then Titel_Short=Titel_Big

    If Text_Big ="" Then Text_Big = Text_Short
    If Text_Short="" Then Text_Short=Text_Big


    If SDK >=16 Then
    Dim nb As NotificationBuilder
    Dim nbBigTextStyle As NotificationBigTextStyle



    If Number>0 Then
    End If
    Dim n As Notification
    "logo" 'use the application icon file for the notification
    If Number>0 Then
    End If
    End If
    End Sub
    this Code Modul is calling from a Service like this:
    Notif.Titel_Big = "Backup"
    "Backup nicht dgf,.kein WLan."
    Notif.Text_Big = 
    "Backup Abgebrochen!, da kein WLan vorhanden ist. Backup wird erneut getartet: " & DateTime.Date(TimeNew) & ", " &  DateTime.Time(TimeNew)
    "Backup wird erneut getartet: " & DateTime.Date(TimeNew) & ", " &  DateTime.Time(TimeNew)
    if i call:
    Notif.Number = 1

    all is o.k.,

    if i call now
    Notif.Number = 2

    the notification #1 show only the Icon, the Text is deleted

    any solution? Thanks
  15. scsjc

    scsjc Well-Known Member Licensed User

    Hi, i use the "setIntent" to open the playstore, with this code and work perfectly

    Dim market As Intenturi As String

    is possible, know when click a notification (before open playstore),
    (i runing the notification inside a service)
  16. barx

    barx Well-Known Member Licensed User

    First thing that comes to mind is instead of using an intent in the notification. Have the notification open your service, do what you want in service and then trigger the intent from service.

    Sounds plausible
    DonManfred likes this.
  17. scsjc

    scsjc Well-Known Member Licensed User

    Great, i try with:

    Dim i as Intent
    Application.PackageName & "/.servicename")
    'StartService(i)  <<< work perfectly with that

    '<<< work only activitys?? or to services ????

    but can't run, can you tellme where is my mistake? i need make a filter manifest????
    thanks !!!!!
    Last edited: Aug 14, 2016
  18. barx

    barx Well-Known Member Licensed User

    I looked over my code and I had this.

    Dim i As Intent
    I haven't played with the code for a while, but I believe it worked fine.
  19. scsjc

    scsjc Well-Known Member Licensed User

    thanks i try
  20. Raywingit

    Raywingit Member Licensed User

    Thanks for the notification conversation, all that participate and improve. So much better than Studio hell, in which I was stuck for a year.
    I am not asking for help yet, but want to share my project. It's on google-play for $1, let me know how to load it into the forum. The program gives time of day as the % left, and verifies universal time is right.
    DarkSide is it's name, since it shows "sun-dial" values at night.

    Next phase is to push time image to wear. So far I have the NBDemo example loaded and running between LG Escape 2 phone, and LG G watch.
    What I need is to update the notification big picture once every 6-10 minutes with the next one. I expect to find holes to fall in but none yet.

    Attached Files:

    • 1.png
      File size:
      50.6 KB
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice