I found an alternative way to obtain altitude by using SensorManager but it requires two paramaters.
public static float getAltitude (float p0, float p)
C
try
List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_PRESSURE);
if(sensors.size() > 0) {
sensor = sensors.get(0);
mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL);
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
public void onSensorChanged(SensorEvent event) {
presure = event.values[0];
}
float altitude = getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, presure);
The current barometric air pressure at sea level (QNH) is the value after the "Q" in the metar field (in hPa - hecto-Pascals). In this case 1000 hPa.
More info on TAF and METAR can be found on wikipedia.
http://en.wikipedia.org/wiki/METAR
http://en.wikipedia.org/wiki/Terminal_aerodrome_forecast