FusedLocationProviderClient

时间:2019-12-02 21:58:59

标签: android fusedlocationproviderclient

通常使用FusedLocationProviderClient来获取我的智能手机的速度,但是即使它躺在我办公室的桌子上不动数小时,其速度值有时也会达到20,有时甚至超过100。 我相信原因是建筑物中的GPS信号不好? 这是我的代码:

locationRequest = new LocationRequest();
locationRequest.setInterval(1000);
locationRequest.setFastestInterval(1000);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
locationCallback = new LocationCallback(){
    @Override
    public void onLocationResult(LocationResult locationResult){
        super.onLocationResult(locationResult);

        for(Location location : locationResult.getLocations()){
            if (location != null) {
                    tv_speedField.setText("" + location.getSpeed());
            }
        }
    }
};

0 个答案:

没有答案