title: Is Android's GPS altitude incorrect due to not including geoid height?
body: <p>I'm testing an Android app that records the location (lat/long/alt). I'm running the app on a Samsung GTS5830 phone running Android 2.2.1 </p>
  
  <p>I read here and there that GPS altitude is often incorrect due to the earth not being perfectly spherical. At my location, for example, <a href="http://earth-info.nga.mil/GandG/wgs84/gravitymod/wgs84_180/intptW.html" rel="noreferrer">the geoid's height</a> is 52 meters.</p>
  
  <p>My understanding is that this height would be substracted from a "pure" GPS altitude. This would make sense for my location as:</p>
  
  <pre><code> - altitude from GPS phone: 535 m
   - geoid altitude: 52 m 
   - altitude from phone's GPS minus geoid height: 482m
  
   - correct atlitude: 478 m 
  </code></pre>
  
  <p>482 is close enough to the real thing for me to track elevation when hiking</p>
  
  <ol>
  <li>Is the above formula of the GPS height minus the geoid's height correct?</li>
  <li>Am I correct to assume that android is not factoring in the geoid's height when returning the GPS altitude?</li>
  <li>If the above is true, does it hold for all versions of Android?</li>
  </ol>
  
  <p>Here is the code I use to obtain the GPS coordinates:</p>
  
  <pre><code>public class HelloAndroid extends Activity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          Log.d("main", "onCreate");
          setupGps();
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
      }
  
      LocationListener locationListener;
      LocationManager lm;
  
      void setupGps() {
          Log.d("gps", "Setting up GPS...");
          locationListener = new MyLocationListener();
          lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
          lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 20000, 5,
                  locationListener);
  
          Log.d("gps",
                  "GPS supports altitude: "
                          + lm.getProvider(LocationManager.GPS_PROVIDER)
                                  .supportsAltitude());
          Log.d("gps", "Finished setting up GPS.");
      }
  
      static class MyLocationListener implements LocationListener {
  
          public void onLocationChanged(Location location) {
              Log.d("gps", "long: " + location.getLongitude() + ", lat: "
                      + location.getLatitude() + ", alt: "
                      + location.getAltitude());
          }
      }
  }
  </code></pre>