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 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);