B4A Library Notification Builder Library.

ilan

Expert
Licensed User
Longtime User
hi

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?

B4X:
                    Dim nb As NotificationBuilder
                    Dim nbBigTextStyle As NotificationBigTextStyle
                    nb.Initialize
                    nb.SmallIcon = "icon"
                    nb.Ticker = "Ticker"
                    nb.ContentTitle = "Recording#####..."
                    nb.DefaultSound = False
                    nb.DefaultVibrate = False
                    nb.ContentText = "Text"
                    nb.ContentInfo = "Info"
                    nb.SubText = "SubText"
                    nb.OnGoingEvent = True
                    nb.AddAction2("recicon","Record","Tag",nbservice)
'                    nb.AddAction2("recicon","Stop","Tag1",nbservice)
                   
                    nbBigTextStyle.Initialize
'                    nbBigTextStyle.BigContentTitle = "Recording#####..."

                    nb.SetStyle(nbBigTextStyle)
                    nb.Notify(1)

thanx
 

Dave O

Well-Known Member
Licensed User
Longtime 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:

Dave O

Well-Known Member
Licensed User
Longtime 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?
 

MohammadNew

Active Member
Licensed User
Longtime User
this library can display notifacation when app. is not working? such as I select spcific time then display it.
 

Dave O

Well-Known Member
Licensed User
Longtime User
this library can display notifacation when app. is not working? such as I select spcific time then display it.

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.
 

ilan

Expert
Licensed User
Longtime 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....

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.
 

barx

Well-Known Member
Licensed User
Longtime 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.
 

ilan

Expert
Licensed User
Longtime 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?

thax
 

barx

Well-Known Member
Licensed User
Longtime 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.
 

Dave O

Well-Known Member
Licensed User
Longtime 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.

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!
 

Attachments

  • notificationTest1.zip
    5.9 KB · Views: 266

barx

Well-Known Member
Licensed User
Longtime 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.

Cheers
 

mw71

Active Member
Licensed User
Longtime User
Hi,

i use a Code Module to Show the notification:
B4X:
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


SDK=p.SdkVersion

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

    nb.Initialize
    nbBigTextStyle.Initialize
  
    nb.OnGoingEvent=False
    nb.AutoCancel=True
    nb.DefaultSound=False
    nb.DefaultVibrate=False
    nb.DefaultLight=False
    nb.SmallIcon="logo"

    nbBigTextStyle.BigContentTitle=Titel_Big
    nbBigTextStyle.BigText=Text_Big
  
    nb.SetStyle(nbBigTextStyle)

    If Number>0 Then
        nb.Notify(Number)
    Else
        nb.Notify(1)
    End If
Else
    Dim n As Notification
    N.Initialize
    n.Icon="logo" 'use the application icon file for the notification
    n.Sound=False
    n.Vibrate=False
    n.SetInfo(Titel_Short,Text_Short,Main)
    If Number>0 Then
        n.Notify(Number)
    Else
        n.Notify(1)
    End If
End If
End Sub

this Code Modul is calling from a Service like this:
B4X:
Notif.Titel_Big = "Backup"
Notif.Titel_Short="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)
Notif.Text_Short="Backup wird erneut getartet: " & DateTime.Date(TimeNew) & ", " &  DateTime.Time(TimeNew)
Notif.NotiBuilder

if i call:
Notif.Number = 1
Notif.NotiBuilder

all is o.k.,

if i call now
Notif.Text_Big.......
Notif.Number = 2
Notif.NotiBuilder

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

any solution? Thanks
 

scsjc

Well-Known Member
Licensed User
Longtime User
Hi, i use the "setIntent" to open the playstore, with this code and work perfectly

B4X:
Dim market As Intent, uri As String
uri="market://details?id=xxxxx.xxxxxxxxxxx.com"
market.Initialize(market.ACTION_VIEW,uri)
......
nb.setIntent(market)


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

barx

Well-Known Member
Licensed User
Longtime 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
 

scsjc

Well-Known Member
Licensed User
Longtime 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


Great, i try with:

B4X:
Dim i as Intent
i.Initialize("", "")
i.SetComponent(Application.PackageName & "/.servicename")
i.PutExtra("MyRequest", "Register")
'StartService(i)  <<< work perfectly with that


.......
nb.setIntent(i)    '<<< work only activitys?? or to services ????
nb.Notify(1)


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

barx

Well-Known Member
Licensed User
Longtime User

I looked over my code and I had this.

B4X:
Dim i As Intent
        i.Initialize(i.ACTION_VIEW, "barxdroid.nbtest.ActionService")
        nb.setIntent(i)

I haven't played with the code for a while, but I believe it worked fine.
 

scsjc

Well-Known Member
Licensed User
Longtime User

thanks i try
 

Raywingit

Member
Licensed User
Longtime 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.
 

Attachments

  • 1.png
    50.6 KB · Views: 250

Raywingit

Member
Licensed User
Longtime User
Update: Extended my images to watch face, but it arrives with a half screen of white, like a blob of gum stuck on it. (the notification strait-jacket)
I get a good-looking display once the notification is swiped off left, BUT the screen fades out after 10 seconds.
If I change the background by sending another BigPicture notification during 10 seconds, the image gets updated but the phone buzzes or beeps every time.
Google has pulled the OnGoingEvent setting, which might have done the trick.
Any ideas on telling the LG G watch not to fall into half-awake mode?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…