首页 > 解决方案 > 如何使用 fusedLocation 获得良好的准确性?

问题描述

在我的应用程序中,我需要跟踪用户位置。为此,我正在使用FusedLocation,从中,我每 10 秒询问一次位置。不幸的是,返回的位置精度为 500.0 米或 164O 英尺。在Android FusedLocationdoc中,规定

精确到几英尺内的位置更新

我的请求设置为:

    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setSmallestDisplacement(10);
    locationRequest.setInterval(30000); // 30 s 
    locationRequest.setFastestInterval(10000); // 10 s
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

另外,我要求粗略和精细位置的许可。

我怎样才能获得更好的准确性?

标签: androidlocationfusedlocationproviderapiandroid-fusedlocation

解决方案


也许您可以尝试询问位置表格,NETWORK_PROVIDER这有助于我解决用户最后已知位置的问题。

这是我的处理方式:

LocationManager locationManager;
locationManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 0, locationListener);
Location lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
LatLng userLocation = new LatLng(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude());

让我知道这是否对您有帮助:)

此致,

迪米塔尔·格奥尔基耶夫


推荐阅读