Hour 12. Using the Gravity and Pressure Sensors

What You’ll Learn in This Hour

Using the gravity sensor

Using the pressure sensor

This hour continues our study of the Android sensors by examining the gravity sensor and pressure sensor, which are two of the more common sensors found in the majority of devices. These sensors might be used for some very interesting games if a creative designer were to put them to use.

Using the Gravity Sensor

The gravity sensor on Android devices reports an algorithmic value based on the linear acceleration sensor. In that regard, it is not a distinct hardware sensor but an algorithm (called a low-pass filter). However, we can still use it to get a decent report on gravity.

The gravity value returned by this ...

Get Sams Teach Yourself Android Game Programming in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.