Hello,
when I am running the below code the application is crashing.
What the code is performing like if the location is same or not changed then no Lat/Long will be send to mqtt. If any location changed happened then the code will throw the new lat/long to mqtt.
But If I omit the above line the application running fine as expected.
The full code is for your reference...
Please advice
when I am running the below code the application is crashing.
What the code is performing like if the location is same or not changed then no Lat/Long will be send to mqtt. If any location changed happened then the code will throw the new lat/long to mqtt.
B4X:
If lastLocation.Latitude <> newloc.Latitude And lastLocation.Longitude <> newloc.Longitude And newloc.Latitude<>0 And newloc.Longitude<>0 Then
But If I omit the above line the application running fine as expected.
The full code is for your reference...
B4X:
Sub Update_Location(newloc As Location)
Dim strLoc As String
If lastLocation.Latitude <> newloc.Latitude And lastLocation.Longitude <> newloc.Longitude And newloc.Latitude<>0 And newloc.Longitude<>0 Then <==== Here i am facing the issue. Without this line application is rununning fine.
lastLocation=newloc
strLoc="lastLocation_" & lastLocation.Latitude & "/" & lastLocation.Longitude '& qrActivity.sessionId
Log(strLoc)
If newloc.IsInitialized Then
Dim CameraPosition1 As CameraPosition 'CameraPosition1.Initialize2(gmap.MyLocation.Latitude, gmap.MyLocation.Longitude, gmap.CameraPosition.Zoom, 0, 0)
CameraPosition1.Initialize(newloc.Latitude,newloc.Longitude, 17)
gmap.moveCamera(CameraPosition1)
Log("Update Location")
ToastMessageShow("Update_Location",True)
Dim bc As ByteConverter
strLoc="newloc_" & newloc.Latitude & "/" & newloc.Longitude '& qrActivity.sessionId
Log(strLoc)
Log("driver_" & qrActivity.sessionId)
mqtt.Publish("driver_" & qrActivity.sessionId,bc.StringToBytes(strLoc ,"UTF8"))
Else
Log("No Update")
End If
End If
End Sub
Please advice