其他分享
首页 > 其他分享> > android – FINE_LOCATION的准确性低于COARSE_LOCATION

android – FINE_LOCATION的准确性低于COARSE_LOCATION

作者:互联网

根据我对在Android上访问位置的理解:

>位置提供程序需要权限ACCESS_COARSE_LOCATION,准确性较低,但检索位置的速度更快.
> GPS提供商需要权限ACCESS_FINE_LOCATION,具有更高的准确性,并且检索位置的速度较慢.

所以更好地理解这一点,我运行了以下代码

//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());
    }
}

虽然网络位置提供商始终给出60.0的准确度,但GPS位置提供商通常会提供较低的准确度.时间更长.

不知道为什么会这样.

解决方法:

精度测量是以米为单位的精度,因此较低的值表示更精确的位置.因此,精确到60.0米范围内的位置可以在任何方向上偏离60米,而精确到5.0米以内的位置最多只能偏离5米.

标签:android,android-location
来源: https://codeday.me/bug/20190630/1338280.html