Hi There,
We have build an app that sends GPS location of android device into a DB. All works fine. But sometimes the location is wrong, It jumps at other country. In the device the GPS is enabled, and getting location based on wireless of celular data is disabled.
Is there any way to prevent these jumps ? Below is the code that we use.
We have build an app that sends GPS location of android device into a DB. All works fine. But sometimes the location is wrong, It jumps at other country. In the device the GPS is enabled, and getting location based on wireless of celular data is disabled.
Is there any way to prevent these jumps ? Below is the code that we use.
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim gpsClient As GPS
Dim userLocation As Location
Dim Completed As Boolean
'
End Sub
Sub Service_Start (StartingIntent As Intent)
gpsClient.Initialize("gpsClient")
userLocation.Initialize
If gpsClient.GPSEnabled=False Then
ToastMessageShow("Please enable your device's GPS capabilities", True)
StartActivity(gpsClient.LocationSettingsIntent)
Else
gpsClient.Start(0, 0)
' ProgressDialogShow("Waiting for GPS location")
End If
End Sub
Sub ExecuteRemoteQuery(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("blah blah.php", Query)
End Sub
Sub JobDone1(Job As HttpJob)
ProgressDialogHide
End Sub
Sub gpsClient_LocationChanged (gpsLocation As Location)
' ProgressDialogHide
userLocation=gpsLocation
gpsClient.Stop
' StartActivity("actDisplayMap")
Dim mystring As String
Dim p As Phone
mystring = p.GetSettings("android_id")
Dim devmodel As String
devmodel = p.Model
Dim speed As Float
speed = userLocation.speed
Dim bearing As Float
bearing = userLocation.bearing
ExecuteRemoteQuery("insert into GPSLog (latitude,longitude,deviceid,speed,bearing) values(" & userLocation.Latitude & "," & userLocation.Longitude & ",'" & mystring & "'," & speed & "," & bearing & ")","job")
StartServiceAt("", DateTime.Now + 15 * DateTime.TicksPerSecond , True)
End Sub
Sub Service_Destroy
End Sub