使用GPS的位置在OREO上返回null

时间:2017-12-23 20:07:24

标签: android gps android-8.0-oreo

我在Android OREO 8.1(Nexus 5X已升级)上测试了我的应用,并且GPS的位置返回null:

LocationManager locationManager = (LocationManager) MyApplication.getInstance().
                getSystemService(Context.LOCATION_SERVICE);

if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
     // With GPS
     location = locationManager.getLastKnownLocation(locationManager, LocationManager.GPS_PROVIDER);
}

location 对象始终为空。

0 个答案:

没有答案