Hi
I'm using this example.
he service code looks like this:
How can I add action buttons (pause, play) to this notification? Or how to replace this notification with NB6 class? Or how to integrate NB6 class with this service?
I'm using this example.
Background task
I'm struggling to create a background task using Tracker as a guide. I have a simple music player that we like but of course it stops when the screen goes off. Where should my Process Globals/Globals and all subs go? Particularly what happens to what was Activity_Create ?
www.b4x.com
B4X:
Sub Process_Globals
Private nid As Int = 1
Private lock As PhoneWakeState
Private pl As SimpleExoPlayer
End Sub
Sub Service_Create
lock.PartialLock
pl.Initialize("pl")
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground
End Sub
Public Sub Play
Service.StartForeground(nid, CreateNotification("Playing music - Radio Paradise"))
pl.Prepare(pl.CreateUriSource("http://stream.radioparadise.com/aac-128"))
pl.Play
End Sub
Sub pl_Error (Message As String)
Log(Message)
End Sub
Sub pl_Complete
Log("complete")
End Sub
Public Sub Stop
Service.StopForeground(nid)
pl.Pause
End Sub
Sub CreateNotification (Body As String) As Notification
Dim notification As Notification
notification.Initialize2(notification.IMPORTANCE_LOW)
notification.Icon = "icon"
notification.SetInfo("Tracking location", Body, Main)
Return notification
End Sub
Sub Service_Destroy
pl.Pause
lock.ReleasePartialLock
End Sub
How can I add action buttons (pause, play) to this notification? Or how to replace this notification with NB6 class? Or how to integrate NB6 class with this service?