O'Reilly logo

Sams Teach Yourself Android Game Programming in 24 Hours by Jonathan S. Harbour

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required