.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 100, 0, this);
.isProviderEnabled(android.location.LocationManager.NETWORK_PROVIDER)) {
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 0, 0, this);//这个只要手机联网百分之百能获取到
}
//上面的获取可能为null,下面的绝对不会为null,前提是手机联网
@Override
public void onLocationChanged(Location location) {
if (location != null) {
myLocation = location;
LogUtils.i("myLocation-changed", "lat:" + myLocation.getLatitude()
+ "lng:" + myLocation.getLongitude());
}
}