#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
Dim user_is_tracking As Boolean
Private nid As Int = 1
Private GPS As GPS
Private Tracking As Boolean
Private LastUpdateTime As Long
Private lock As PhoneWakeState
End Sub
Sub Service_Create
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
GPS.Initialize("gps")
lock.PartialLock
End Sub
Sub Service_Start (StartingIntent As Intent)
If user_is_tracking Then
Service.StartForeground(nid, CreateNotification("..."))
StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
Track
Else
lock.ReleasePartialLock
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
End If
End Sub
Public Sub Track
If Tracking Then Return
If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
Log("No permission")
Return
End If
GPS.Start(0, 0)
Tracking = True
End Sub
.
.
.