April 2016
Intermediate to advanced
194 pages
4h 37m
English
The procedure to get values from the phone's pressure sensor is exactly the same as the previous example showing getting values from temperature sensors. The only difference is the sensor type. To get values from the pressure sensor, we have to specify the sensor type as TYPE_PRESSURE. All other best practices (initiating SensorManager, the Sensor object, and registering and unregistering the listener and sensor callback) remain the same as they were in the previous temperature sensor example.
Once we have atmospheric pressure from the phone's pressure sensor, we can calculate the altitude of the phone using the getAltitude(float ...