No puedo obtener la ubicación a través del GPS con el locationmanager, no devuelve la llamada onLocationChanged, no funciona ni en interiores ni en exteriores, no funciona cuando te mueves, está probado con la máquina real.
Código:
private LocationListener listener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
LogUtil.e("onLocationChanged");
if (location == null) {
return;
}
ToastUtil.showShortToast(MyApplication.getInstance().getApplicationContext(), "GetLocation" + location.getLatitude() + "");
//latitude
LogUtil.e(location.getLatitude() + "");
//longitude
LogUtil.e(location.getLongitude() + "");
sendLocation(location.getLatitude() + "", location.getLongitude() + "");
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
/* Even if a provider is enabled, it doesn't mean that it can listen to location information from him, for example, GPS is enabled, but it can't search for satellites.
The status includes: OUT_OF_SERVICE, TEMPORARILY_UNAVAILABLE and AVAILABLE*/
}
@Override
public void onProviderEnabled(String provider) {
/* When the user turns on a location provider in the system settings */
}
@Override
public void onProviderDisabled(String provider) {
/* When the user disables a provider in the system settings. If a provider is disabled, when a location is registered with the system via requestLocationUpdate()
registers the listening location with the system, onProviderDisabled() will be triggered immediately. */
}
};
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, listener);