As per my understanding of accessing Location on Android:
- The Location Provider needs permission ACCESS_COARSE_LOCATION, has a lower accuracy, but is faster in retrieving location.
- The GPS provider needs permission ACCESS_FINE_LOCATION, has a higher accuracy, and is slower in retrieving location.
So understand this better, I ran the following code
//Go through a list of all location providers to get the "best" one
List<String> locationProviders = locationManager.getAllProviders();
for (String locationProviderInit : locationProviders) {
Log.d(DEBUG_TAG, "found locationProvider:" + locationProviderInit);
Location lastKnownLocation = locationManager.getLastKnownLocation(locationProviderInit);
if (lastKnownLocation != null) {
Log.d(DEBUG_TAG, "accuracy: " + lastKnownLocation.getAccuracy());
Log.d(DEBUG_TAG, "time: " + lastKnownLocation.getTime());
}
}
While the network location provider consiste开发者_如何学Pythonntly give an accuracy of 60.0, the GPS location provider usually gives accuracy lower & time higher.
Not sure why this is happening.
The accuracy measurement is the accuracy of the location in metres, so a lower value indicates a more precise location. So a location accurate to within 60.0 metres could be off by up to 60m in any direction, whereas a location accurate to within 5.0 meters will only be off by up to 5m.
精彩评论