Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim GPS1 As GPS
Dim GPSMinTime As Long = 0
Dim GPSMinDistance As Float = 10
Dim GPSPathPreviuous As Location
Dim dblTotalDistance As Float
Dim timerSpeed As Timer
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private lblSpeedStatus As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("frmMain")
If FirstTime = True Then
timerSpeed.Initialize("timerSpeed",2000)
GPS1.Initialize("GPS1")
End If
timerSpeed.Enabled=True
End Sub
Sub Activity_Resume
If GPS1.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
GPS1.Start(GPSMinTime, GPSMinDistance)
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If GPS1.GPSEnabled Then
GPS1.stop
End If
End Sub
Sub timerSpeed_Tick
'Aktuelle Geschwindigkeit auf null setzen
If lblSpeedStatus.Tag = dblTotalDistance Then
lblSpeedStatus.Text = "0.00"
End If
End Sub
Sub GPS_LocationChanged (Location1 As Location)
Dim locDistance As Float
If Location1.SpeedValid Then
If Location1.Speed > 0 Then
If GPSPathPreviuous.Speed > 0 Then
locDistance = GPSPathPreviuous.DistanceTo(Location1)
dblTotalDistance = dblTotalDistance + locDistance
End If
GPSPathPreviuous = Location1
End If
'Aktuelle Geschwindigkeit anzeigen
lblSpeedStatus.Text = NumberFormat2(Location1.Speed, 1, 2, 2, False)
lblSpeedStatus.Tag = dblTotalDistance
End If
End Sub