FusedLocationProviderClient API API LocationRequest setSmallestDisplacement无法正常工作

时间:2018-08-14 11:23:00

标签: android fusedlocationproviderapi

我希望我的应用每分钟获取一次位置更新,同时考虑15米的最小位移。我定义了locationRequest,如下所示:

mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(60000);
mLocationRequest.setFastestInterval(60000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setSmallestDisplacement(15); //15 meters

位置:

mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper());

LocationCallback实例为:

LocationCallback mLocationCallback = new LocationCallback(){
    @Override
    public void onLocationResult(LocationResult locationResult) {
        for (Location location : locationResult.getLocations()) {
            Log.d(TAG, "Location: " + location.getLatitude() + " " + 
                location.getLongitude());
        }
    };
};

现在问题是无论设备静止还是移动1米,我都可以获取位置更新。 我设置了一个文本视图来显示坐标更新,这就是它所显示的内容(重复坐标或小于15m的微小移动): Screenshot

0 个答案:

没有答案