【发布时间】:2016-02-09 09:07:52
【问题描述】:
我正在使用下面的代码来获取 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。可能是什么原因?
【问题讨论】:
标签: android google-maps location latitude-longitude