FusedLocationProviderClient 有时会给出不同的位置

FusedLocationProviderClient gives different location sometimes

 public void getDeviceLocation() {
        fusedLocationClient = LocationServices.getFusedLocationProviderClient(getMvpView().getActivity());
        settingsClient = LocationServices.getSettingsClient(getMvpView().getActivity());
        createLocationCallback();
        createLocationRequest();
        buildLocationSettingsRequest();
        startLocationUpdates();
    }


    private void createLocationRequest() {
        locationRequest = new LocationRequest();
        locationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
        locationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
        locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    }


    private void createLocationCallback() {
        getMvpView().showProgressDialog();
        locationCallback = new LocationCallback() {
            @Override
            public void onLocationResult(LocationResult locationResult) {
                super.onLocationResult(locationResult);
                Location currentLocation = locationResult.getLastLocation();
                getMvpView().showSelectedAddress(getAddressFromLatLng(currentLocation.getLatitude(), currentLocation.getLongitude()));
                fusedLocationClient.removeLocationUpdates(locationCallback);
                getMvpView().hideProgressDialog();
            }
        };
    }


    private void buildLocationSettingsRequest() {
        LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
        builder.addLocationRequest(locationRequest);
        locationSettingsRequest = builder.build();
    }


    private void startLocationUpdates() {
        settingsClient.checkLocationSettings(locationSettingsRequest)
                .addOnSuccessListener(getMvpView().getActivity(), locationSettingsResponse -> {

                    if (ActivityCompat.checkSelfPermission(getMvpView().getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getMvpView().getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                        return;
                    }
                    fusedLocationClient.requestLocationUpdates(locationRequest,
                            locationCallback, Looper.myLooper());

                }).addOnFailureListener(getMvpView().getActivity(), e -> {
            getMvpView().hideProgressDialog();
            getMvpView().showErrorToast(R.string.please_enable_location);
        });
    }


    @SuppressLint("MissingPermission")
    private void startLocationUpdates() {
        settingsClient.checkLocationSettings(locationSettingsRequest)
                .addOnSuccessListener(getMvpView().getActivity(), locationSettingsResponse -> {
                    fusedLocationClient.requestLocationUpdates(locationRequest,
                            locationCallback, Looper.myLooper());

                }).addOnFailureListener(getMvpView().getActivity(), e -> {
            getMvpView().hideProgressDialog();
            getMvpView().showErrorToast(R.string.please_enable_location);
        });
    }


    private String getAddressFromLatLng(double latitude, double longitude) {
        Geocoder geocoder = new Geocoder(getMvpView().getActivity(), Locale.getDefault());
        List<Address> addresses = null;
        try {
            addresses = geocoder.getFromLocation(
                    latitude,
                    longitude,
                    1);
        } catch (IOException e) {
            e.printStackTrace();
        }

        Address address = addresses.get(0);
        StringBuilder addressStringBuilder = new StringBuilder();
        for (int i = 0; i <= address.getMaxAddressLineIndex(); i++) {
            addressStringBuilder.append(address.getAddressLine(i));
        }

        return addressStringBuilder.toString();
    }

我已将纬度、经度转换为地址文本,但在我再次查询位置后,即使我没有离开当前位置,地址也会发生变化,phone 设置中也启用了准确性。问题是当我总是查询它应该给我相同的位置地址,如果我的纬度,经度位置没有改变。

FusedLocationProviderClient 表示结合 gps 和 google-translating-received-wlan-cellphone-tower-signals-to-lat-lon.

google-translating-received-wlan-cellphone-tower-signals-to-lat-lon 是一种不精确的启发式方法,除其他因素外,它还取决于哪个 cellphone-tower your handy 连接到(google 每个塔有 lat/lon)以及最强的 3 cellphonetowers 有多强。

如果你的 cellphone 改变了它的 cellphone-tower-connection 那么对于 googl-s 算法你的 phone 位置已经改变。

如果您的小区phone可以接收超过 3 个小区phone 信号塔,最强的 3 个小区phone信号塔也会根据每个小区信号塔的流量而变化。

gps 接收器消耗大量能量。当启用 gps-energy-optimisation 时,可能还会有 gps-precision issuses 导致融合位置跳跃。

我第一次用我的新手机进行地理寻宝时学到了这一点,我想知道为什么我自己的位置在地图上跳了起来