#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
Public FProvider As FileProvider ' class FileProvider. Para el email con permisos, android 6.0.1 y superior
'
Public rp As RuntimePermissions
Public mGPS As GPS
Public mLM As LocationManager
Private bGpsStarted As Boolean
'
Dim fLastLatitudGPS, fLastLongitudGPS, fLastAlturaGPS, fLastTimeGPS As Double ''', fLastSpeedGPS As Double
Dim fLastLatitudTTM, fLastLongitudTTM, fLastAlturaTTM, fLastTimeTTM As Double ''', fLastSpeedTTM As Double
'
End Sub
Sub Service_Create
FProvider.Initialize ' lo del email, adjuntar fichero y ese rollo.
'
mGPS.Initialize("mGPS") ' ubicación mediante GPS
mLM.Initialize("mLM") ' ubicación mediante triangulación torres telefonía móvil
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Public Sub StartGps
If Not(bGpsStarted) Then
mGPS.Start(500, 0) ' gps
bGpsStarted = True
'
Try
mLM.requestMobileLocation ' torres telefonía móvil
Catch
Log(LastException)
End Try
End If
End Sub
Public Sub StopGps
If bGpsStarted Then
mGPS.Stop
bGpsStarted = False
'
Try
mLM.stopMobileListening ' torres triangulación
Catch
Log(LastException)
End Try
End If
End Sub
Sub mGPS_LocationChanged (Location1 As Location)
''' CallSub2(Main, "LocationChanged", Location1)
''' Dim const dFactorMS2KMH As Double = 3.6
'
fLastLatitudGPS = Location1.Latitude
fLastLongitudGPS = Location1.Longitude
fLastAlturaGPS = Location1.Altitude ' m
fLastTimeGPS = Location1.Time
''' fLastSpeedGPS = Location1.Speed * dFactorMS2KMH ' pasar de m/s a km/h
End Sub
Sub mLM_LocationChanged (Longitude As Double, Latitude As Double, Altitude As Double, Accuracy As Float, Bearing As Float, Provider As String, Speed As Float, Time As Long)
''' Dim const dFactorMS2KMH As Double = 3.6
'
fLastLatitudTTM = Latitude
fLastLongitudTTM = Longitude
fLastAlturaTTM = Altitude
fLastTimeTTM = Time
''' fLastSpeedTTM = Speed * dFactorMS2KMH
End Sub
'''Sub GPS_GpsStatus (Satellites As List)
''' CallSub2(Main, "GpsStatus", Satellites)
'''End Sub
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
StopGps
End Sub