I am working on gps tracking apps in android. Here is my code architecture:
- BackgroundSyncService : A service class that is used for getting location update. Here GoogleApiClient is initialized and implements others Location related methods.
- AppRunCheckerReceiver : A BroadcastReceiver class that will check if my
BackgroundSyncService
is running or not in a time interval. If it stopped then it start. - GpsEnableReceiver : A BroadcastReceiver it will fire if gps status changed. It will check if my
BackgroundSyncService
is running or not in a time interval. If it stopped then it start. - InternetConnectionStateReceiver : A BroadcastReceiver it will fire when internet status changed. It will check if my
BackgroundSyncService
is running or not in a time interval. If it is stopped, then it start.
In my BackgroundSyncService
service I initialize the GoogleApiClient using this way:
public void setLocationLocationRequest() {
try {
googleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(com.google.android.gms.location.LocationServices.API).build();
locationRequest = new LocationRequest();
locationRequest.setInterval(3000);
locationRequest.setFastestInterval(3000);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
googleApiClient.connect();
} catch (Exception e) {
}
Here accuricy is LocationRequest.PRIORITY_HIGH_ACCURACY
and interval is
locationRequest.setInterval(3000)
here is the GoogleApiClient implementation code.
This application GPS info section contains Latitude longitude and Accuracy parameter
My Findings: in onLocationChanged(Location location)
method I check the accuracy of Location object in this way : location.getAccuracy()
. Here if accuracy is less than 50 meter, then I accept it.
In 85% of the cases it working like a charm. It sending me exact location from GPS. But in 15% cases, it sending me inaccurate location like more >300 meter.
The 15% device are low cost China brand mobile.
My Questions:
- How can i make accuracy level near 99%. Is there any problem on my code architecture?
- Does GPS accuracy depends on device configuration? if YES then what can I do for low configuration device?
- How Uber, Go-JEK etc. ride sharing apps works for all device? Is they have extra coding for GPS only?
- My application is for Bangladesh. Here internet is slow. Is it has negative impact on GPS accuracy?
Thanks in advance for this thread. And also sorry for bad english.
FusedLocationProviderAPI
? – Piyush