Android Question what to pass to NB6 notification in the activity field when using B4XPages calling NB6.build from a service?

omarruben

Active Member
Licensed User
Longtime User
B4X:
Sub CreateNotification2(Body As String) As Notification
    Dim n As NB6
   n.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(iconx)
   n.Build("Playing", Body, "tag1",--->ACTIVITY<---).Notify(4) 'It will be Main (or any other activity) instead of Me if called from a service.
End Sub

what should be there ? I did try main and i got and error
 

Apip Bayok

Member
B4X:
Dim n As NB6
        n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(smiley)
        n.OnlyAlertOnce(True)
        Dim cs As CSBuilder
        n.BigTextStyle("APP NAME", cs.Initialize.BackgroundColor(Colors.Red).PopAll,Message.GetData.Get("msg"))
        Dim notification As Notification = n.Build("APP NAME", "...", "Waiting", Main)
        notification.Notify(2)

Try like this
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
When using Activity as object in B4XPages, you should use:
B4X:
B4XPages.GetNativeParent(Me)
or
B4X:
Dim Act As Activity = B4XPages.GetNativeParent(Me)
but in this case is does not work. I think that Erel should modify NB6 to work with B4XPages (I could be wrong, of course).
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Check this example to check how Erel does it

 
Upvote 0

omarruben

Active Member
Licensed User
Longtime User
still have an error:
in the background service :
B4X:
Service.StartForeground(nid, CreateNotification2("Playing ..."))

this function spects a notification type value to be return

in the function I am using NB6 , that is not a notification type, so what do I have to return?

B4X:
Sub CreateNotification2(Body As String) As Notification
  
    Dim n As NB6
    Dim Act As Activity = B4XPages.GetNativeParent(Me) ' because we are using B4XPages
  
  
    n.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(iconx)
    n.Build("Playing", Body, "tag1",Act).Notify(4) 'It will be Main (or any other activity) instead of Me if called from a service.
    return ??????
End Sub
 
Last edited:
Upvote 0
Top