Android Question Calling Notification without StartForeground

Scantech

Well-Known Member
Licensed User
Can i call the bottom notification without StartForeground? Will it cause any issue with late android version? It seems to be working ok with Android 7. Android 8+ requires channels. Is the importance_low considered as channels?

B4X:
    Dim n As Notification = CreateNotification(WhatMessage)
    n.Notify(1)

Sub CreateNotification (Body As String) As Notification
    Dim notification As Notification
    notification.Initialize2(notification.IMPORTANCE_LOW)
    notification.Sound = False
    notification.Vibrate = False
    notification.Icon = "icon"
    notification.SetInfo("Status", Body, Starter.WhatFormName)    'can't use main. unless last known activity then it will be ok
    Return notification
End Sub
 

Scantech

Well-Known Member
Licensed User
I have not tried it yet but to use NB6 i need to replace?
B4X:
Sub CreateNotification (Body As String) As Notification
to
B4X:
Sub CreateNotification (Body As String) As NB6
 

Scantech

Well-Known Member
Licensed User
I was hoping i can use Service.StartForeground(1, CreateNotification("...")) with NB6 but unfortunately it can't work. My service uses Service.StartForeground(1, CreateNotification("...")) which is not removable and i wanted to add a button to it. I do not want to create a new channel which i am sure its doable with NB6. I want to keep it at 1 channel only.

Or can i update the Service.StartForeground(1, CreateNotification("...")) channel with NB6 which contains buttons? I need to try that.
 

Scantech

Well-Known Member
Licensed User
Sorry let me rephrase what I am trying to say.

I do this in the Service Start
B4X:
Service.StartForeground(1, CreateNotification("..."))
B4X:
Sub CreateNotification (Body As String) As Notification
    Dim notification As Notification
    notification.Initialize2(notification.IMPORTANCE_LOW)
    notification.Sound = False
    notification.Vibrate = False
    notification.Light = False
    notification.Icon = "icon"
    notification.SetInfo("Status", Body, Starter.WhatFormName)
    Return notification
End Sub
Then the Channel 1 gets updated by this. I can override that channel with NB6 instead of Internal Notification.
B4X:
Sub BigText_Notification2(Body As String, Body2 As String)
    'the behavior will not be same if channels is changed or setdefaults
    Dim n As NB6
    n.Initialize(1, Application.LabelName, "LOW").SmallIcon(TripIcon2).AutoCancel(True)
    n.SetDefaults(False, False ,False)
    n.BigTextStyle("Status", "", Body2)
    n.Build("Status", Body, "tag2", Starter.WhatFormName).Notify(1)
End Sub
It seems to be working OK.

After reading the above statements, same here i do not understand what i was saying, i get off subject sometimes. But i found what i was looking for in the above codes.
 
Last edited:
Top