Android Question FLP, speed never return to zero

Mostez

Well-Known Member
Licensed User
Longtime User
I use this FLP code for tracking, it seems that it works ok, but speed never return to zero when vehicle stopped, I always get the last updated speed say 20, and it never changed unless the vehicle move again, any ideas to fix that?

TIA

B4X:
Private Sub flp_LocationChanged (Location1 As Location)
    CallSubDelayed2(Home,"Update",Location1)
    If DateTime.Now > LastUpdateTime + 20 * DateTime.TicksPerSecond Then
        Dim GPStext As String = "Location: " & $"$2.5{Location1.Latitude},$2.5{Location1.Longitude}"$ & " Speed kmh: " & (Location1.Speed * 3.6)
        MyLocation.Info.RefNumber = St.GetRandomID
        MyLocation.Info.Latitude = Location1.Latitude
        MyLocation.Info.Longitude = Location1.Longitude
        MyLocation.Info.Speed = Location1.Speed 'never return to zero if vehicle stopped
        MyLocation.Info.DeviceID = Di
        MyLocation.Info.PhoneNumber = ""
        Wait For (MyLocation.Save) complete (Saved As Boolean)
        
        If Not(Saved) Then
            MyLocation.LogEvent(GPStext)
        End If
        Dim n As Notification = CreateNotification(GPStext)
        n.Notify(nid)
        LastUpdateTime = DateTime.Now
    End If
End Sub

Private Sub CreateLocationRequest() As LocationRequest
    Dim lr As LocationRequest
    lr.Initialize
    lr.SetSmallestDisplacement(10) '10 meters
    lr.SetInterval(1000)
    lr.SetFastestInterval(lr.GetInterval / 2)
    lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY)
    Return lr
End Sub
 
Top