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.