The return value from the getAltitude() method always returns 0.00. Many answers suggest it could be down to the provider not supporting altitude details. I have checked this and it does support altitude.
I want to obtain the altitude from GPS coordinates. Any help is appreciated.
My code can been seen below.
LocationManager locationManager; LocationProvider locationProvider;
/* Get LocationManager and LocationProvider for GPS */
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationProvider = locationManager.getProvider(LocationManager.GPS_PROVIDER);
/* Check if GPS LocationProvider supports altitude */
locationProvider.supportsAltitude();
//Location object
Location l = new Location("A");
l.setLatitude(40.796852);
l.setLongitude(-74.061340);
l.getAltitude();
//Returns 0.00
Log.i("Tag", String.valueOf(l.getAltitude()));
//returns True
Log.i("Tag", String.valueOf(locationProvider.supportsAltitude()));