/ *** SERVICE #1
Sub Service_Start (StartingIntent As Intent)
' // setup the notification
Service.StopAutomaticForeground
Service.StartForeground(nID,CreateNotification("Title","text","logo",Main,False,False))
pw.PartialLock
End Sub
Private Sub CreateNotification(Title As String, Content As String, Icon As String, TargetActivity As Object, Sound As Boolean, Vibrate As Boolean) As Notification
Dim p As Phone
If n.IsInitialized Then
n.Cancel(nID)
End If
If p.SdkVersion >= 21 Then
Dim nb As NotificationBuilder
Dim Channel As NotificationChannelBuilder
Dim ChannelID As String = "ies_atlas_hello"
Dim ChannelName As String = "Atlas Hello"
' // Build a Channel
If Channel.ChannelsSupported Then
Channel.Initialize(ChannelID, ChannelName, Channel.IMPORTANCE_LOW)
Channel.Build
End If
nb.Initialize(ChannelID)
nb.AutoCancel = False
nb.OnGoingEvent = True
nb.DefaultSound = False ' sound
nb.DefaultVibrate = False ' vibrate
nb.DefaultLight = False
nb.ContentTitle = Title
nb.ContentText = Content
nb.setActivity(TargetActivity)
nb.SmallIcon = Icon
nb.ShowTime = False
nb.Number = nID
' //set the return object for the notification object (n1) in this service
n = nb.GetNotification
Else
n.Initialize
n.Number = nID
n.Light = False
n.Vibrate = False
n.Sound = False
n.OnGoingEvent = True
n.Icon = Icon
n.SetInfo(Title, Content, TargetActivity)
End If
n.Notify(nID)
Return n
End Sub
/ *** SERVICE #2
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground
' // hook to the forground notification in the service #1
Service.StartForeground(service1.nID, service1.n)
pw.PartialLock
End Sub