Sub Service_Create
'TripGPSDistance
CheckPreferenceState
'we don't need this when gps setting is off. must avoid this or crashing can occur
If StateManager.blnUseGPS = True Then
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
End If
GPS1.Initialize("GPS")
tmrTrip.Initialize("tmrTrip", 500) 'every 500 milliseconds
tmrTripSaveData.Initialize("tmrTripSaveData", 60000) '1 minutes
PhoneEvent.Initialize("PhoneEvents")
StateManager.LoadStateTrip 'load these
StateManager.LoadStateMaintenance 'load these at first startup
StateManager.LoadStateSpeedLimiter 'load speed limiter value
Starter.pws.PartialLock 'Important so it will not CPU Sleep
TripIcon1 = LoadBitmapResize(File.DirAssets, "tripicon.png", 24dip, 24dip, True)
TripIcon2 = LoadBitmapResize(File.DirAssets, "mainicon.png", 24dip, 24dip, True)
End Sub
Sub Service_Start (StartingIntent As Intent)
StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True) '30 minutes
'avoid this if gps settings in app is off
If StateManager.blnUseGPS = True Then
Service.StartForeground(1, CreateNotification("..."))
tmrNotification_OBD_GPS_Mode_Status(2)
TurnOnTmrTrip
Else
Service.StopAutomaticForeground
End If
End Sub