Location Changed event acting strangely?

Smee

Well-Known Member
Licensed User
Longtime User
I have a tablet in a stastionary position and the LocationChanged event fires often and fast

I put a counter in the event and it increments by 4 at a time:confused:

It is a simple test program

B4X:
Sub Activity_Resume
    StartGPS
End Sub

Sub Activity_Pause (UserClosed As Boolean)
   GPS1.Stop
End Sub

Sub GPS_GpsStatus (Satellites As List)
  Dim st As Int
  Dim Status As String
  st=0
  For i = 0 To Satellites.Size - 1
    Dim Satellite As GPSSatellite
    Satellite = Satellites.Get(i)
    If Satellite.UsedInFix=True Then st=st+1
      If st>0 Then 
        Status=st
      Else
        Status="Lost GPS!"
     End If
  Next
  If st>2 Then Return
  ToastMessageShow(Status,True)
  
Sub StartGPS
Try
If GPS1.GPSEnabled = False Then
    ToastMessageShow("Please enable the GPS device.", True)
    StartActivity(GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
  Else
    GPS1.Start(0, 0) 'Listen to GPS with no filters.
  End If
 Catch
 End Try
'sTART ANYWAY FOR TESTING
 GPS1.Start(0, 0) 'Listen to GPS with no filters.
 
End Sub

Sub GPS_LocationChanged (Location1 As Location)
   MyLatitude = NumberFormat(Location1.Latitude,3,4)
           MyLongitude = NumberFormat(Location1.Longitude,3,4)
   lblLocation.Text=MyLatitude 
   lblLocation2.Text=MyLongitude
   Counter=Counter+1
   lblCounter.Text =Counter
   
End Sub

Can any one see what is wrong here?


UPDATE:

Ok i can see where i have gone wrong with the start command not using filters. But the increment still sdhows 4 at a time
 
Last edited:
Top