I\'ve a challenges task for getting very high accuracy. So I am using GPS_PROVIDER. But my code is getting incorrect accuracy. some time it
In the OnLocation
method check the location accuracy if it's not suitable the next call to OnLocation
will generally be more accurate. More accuracy requires more work. You've seen the google map display a circle around the location and possibly watched it decrease in size. The radius of the circle is based on the location accuracy witch is a property of Location.
The below method works great. I have extensively tested it while driving, biking, walking the dog, and on the Harley. It filters out going in Mcd's and having the location come up in Texas where the Mcd's wifi provider is based and those pesky off by 100m locations.
@Override
public void onLocationChanged(Location location) {
if (!location.hasAccuracy()) {
return;
}
if (location.getAccuracy() > myDesiredAccuracy) {
return;
}
//blah what your app does...
isCompleted=true;
System.out.println("onLocationChanged 1");
// Called when a new location is found by the GPS location provider.
if(isBetterLocation(location, loc)){
// Toast.makeText(getBaseContext(), "yes", Toast.LENGTH_LONG).show();
System.out.println("onLocationChanged 2");
gotLocation(location);
}
System.out.println("onLocationChanged 3");
clearListener();
setUserPoint();
}
Note: Sometimes you get into a dead spot where you just can't get good GPS reception. These are caused by being inside a building, power lines, line of sight, cut freeways, unmapped wifi in buildings, other devices emitting radio signals that interfere with the GPS satellite reception. Basically anything that can interfere with radio reception can interfere with GPS.
Consumer GPS receivers have an acuracy of 2.5-6m in 95% of cases, you cannot improve that for moving devices.
If you stand still (by user interaction that tells start of standstill, and end-of-standstill), you can calculate the average position.
Especially when standing still GPS chips have a bit less acuracy because the doppler shift can only be used while moving.
To caluclate the accuracy of your device you should take some measures, caluclate the average position, and calculate for each measure the distance to that average position. This then should give a value between 3-6m.
You wrote, that you expect 0m distance between two location while standing still.
But this does not work with GPS. Due fluctating conditions in the troposphere, the signal delay slightly vary, causing jumping position while standing still.
You only get 0m if you have enabled a stand still filter, which iOS uses by default. There should also a possibility in Android to enable such a filter (E.g by setting distance threshold to a value higher than 0).