开发者

FINE_LOCATION has less accuracy than COARSE_LOCATION

开发者 https://www.devze.com 2023-03-16 14:56 出处:网络
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.

As per my understanding of accessing Location on Android:

  1. The Location Provider needs permission ACCESS_COARSE_LOCATION, has a lower accuracy, but is faster in retrieving location.
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消