我使用下面的代码来获得的LatLong入门经纬度,我也使用NetWorkProvider得到LatLong网:使用网络提供商
下面的代码工作正常:
// if GPS Enabled get lat/long using GPS Services
if (isGPSEnabled) {
if (mLocation == null) {
mLocationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
5000,
5000, this);
if (mLocationManager != null) {
mLocation = mLocationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (mLocation != null) {
//Called here...
onLocationChanged(mLocation);
}
}
}
}
但是,当我使用下面的代码:
if (isNetworkEnabled) {
mLocationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
5000,
5000, MainActivity.this);
if (mLocationManager != null) {
mLocation = mLocationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (mLocation != null) {
onLocationChanged(mLocation);
}
}
}
我正在获取mLocation null
。可能是什么原因?
同样的问题,获取位置空,当我commiting如果回路isGPSEnableb,但亚其取消注释,并检查使用GPS的工作。 – user5716019