Hi,
Would below code make sure that the service never will be killed?
Thanks in advance.
Would below code make sure that the service never will be killed?
Thanks in advance.
B4X:
Sub Service_Create
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
lock.PartialLock
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StartForeground(nid, CreateNotification("..."))
StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
End Sub
Sub Service_Destroy
lock.ReleasePartialLock
Service.StopAutomaticForeground
CancelScheduledService(Me)
End Sub
Sub CreateNotification (Body As String) As Notification
Dim notification As Notification
notification.Initialize2(notification.IMPORTANCE_LOW)
notification.Icon = "TrainClock36x36"
notification.Sound = False
notification.Vibrate = False
notification.SetInfo("Tracking location", Body, Main)
Return notification
End Sub