I get the altitude always 0. I want to obtain the altitude above sea level in Android using GPS.
My code is:
public void onLocationChanged(Location location) {
double lat = (double) (location.getLatitude());
double lng = (double) (location.getLongitude());
double alt = (double) (location.getAltitude());
latitudine = (int) (lat * 1e6);
longitudine = (int) (lng * 1e6);
altitudine = (int) (alt * 1e6);
}
Did you check if this is device specific? Are you working in an emulator?
I would at first check, if your device supports the altitude determination with:
If you want to know if a location has a valid altitude set, use the following: