mFusedLocationClient返回null(大小写:设备离线,GPS打开)

时间:2017-12-11 15:04:37

标签: java android google-api gps

我正在尝试添加新版本的FusedLocationClient。我想在某种情况下这样做,我的手机处于离线模式,GPS开启!

我做了什么==>

mFusedLocationClient = LocationServices.getFusedLocationProviderClient(getApplicationContext());

 LocationCallback locationCallback = new LocationCallback() {
                    @Override
                    public void onLocationResult(LocationResult locationResult) {
                        super.onLocationResult(locationResult); // why? this. is. retarded. Android.
                        Location currentLocation = locationResult.getLastLocation();
                        System.out.println("Loc => " + currentLocation.getLatitude());
                    }

                    ;
                };
mFusedLocationClient.requestLocationUpdates(mLocationRequest, locationCallback, Looper.myLooper());

但是当我打印它时我得到一个null结果。我真的不明白为什么。如果有人能向我解释什么是错的,那就太大了!

0 个答案:

没有答案