我需要一些关于LocationManager
Android 的信息/帮助的帮助。我正在使用此代码根据用户的位置获取用户的特定信息,但在某些情况下我得到了provider=null
(我不太确定何时,因为该异常已上传到我们的服务器并且我无法重现它)。
这是示例代码:
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria crta = new Criteria();
crta.setAccuracy(Criteria.ACCURACY_FINE);
crta.setAltitudeRequired(false);
crta.setBearingRequired(false);
crta.setCostAllowed(true);
crta.setPowerRequirement(Criteria.POWER_LOW);
String provider = locationManager.getBestProvider(crta, true);
Log.d("","provider : "+provider);
// String provider = LocationManager.GPS_PROVIDER;
Location location = locationManager.getLastKnownLocation(provider);
updateWithNewLocation(location);
locationManager.requestLocationUpdates(provider, 1000, 0, locationListener);
当我的提供者为空并且有办法获取当前位置并使用它时,我该怎么办?
提前致谢!