I need accurate GPS location in my Android app. I am using this Cordova plugin to achieve GPS locations: https://github.com/pmwisdom/cordova-background-geolocation-services
This is the code that requests GPS location:
if (locationClientAPI == null) {
connectToPlayAPI();
} else if (locationClientAPI.isConnected()) {
locationRequest = LocationRequest.create()
.setPriority(translateDesiredAccuracy(LocationRequest.PRIORITY_HIGH_ACCURACY))
.setFastestInterval(4000)
.setInterval(5000)
.setSmallestDisplacement(0);
LocationServices.FusedLocationApi.requestLocationUpdates(locationClientAPI, locationRequest, locationUpdatePI);
this.isRecording = true;
if(isDebugging) {
Log.d(TAG, "- Recorder attached - start recording location updates");
}
} else {
locationClientAPI.connect();
}
It works an many Android phones, but on some (for example Samsung Galaxy S8) the accuracy is VERY bad. Often 500-1500m which is completely unusable for the app. I have also observed that if I open Google Maps at the same time, the location is also all over the place, UNTIL I start route guidens - then it becomes spot on, almost instantly. And if I use my app, while route guidens is on, everything is very accurate and nice.
In Android settings my app is allowed to use the highest GPS accuracy.
How can I achieve the high accuracy without having to enable route guidance in google maps.