SensorManager.GetAltitude(Single, Single) Method

Definition

Computes the Altitude in meters from the atmospheric pressure and the pressure at sea level.

[Android.Runtime.Register("getAltitude", "(FF)F", "")]
public static float GetAltitude (float p0, float p);
[<Android.Runtime.Register("getAltitude", "(FF)F", "")>]
static member GetAltitude : single * single -> single

Parameters

p0
Single

pressure at sea level

p
Single

atmospheric pressure

Returns

Altitude in meters

Attributes

Remarks

Computes the Altitude in meters from the atmospheric pressure and the pressure at sea level.

Typically the atmospheric pressure is read from a Sensor#TYPE_PRESSURE sensor. The pressure at sea level must be known, usually it can be retrieved from airport databases in the vicinity. If unknown, you can use #PRESSURE_STANDARD_ATMOSPHERE as an approximation, but absolute altitudes won't be accurate.

To calculate altitude differences, you must calculate the difference between the altitudes at both points. If you don't know the altitude as sea level, you can use #PRESSURE_STANDARD_ATMOSPHERE instead, which will give good results considering the range of pressure typically involved.

<ul> float altitude_difference = getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, pressure_at_point2) - getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, pressure_at_point1); </ul>

Java documentation for android.hardware.SensorManager.getAltitude(float, float).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to