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 10. Using the Accelerometer

What You’ll Learn in This Hour

• About the Android sensors

• How to access Android sensors

• How to disable screen rotation

• How to use the accelerometer

This hour covers the broader subject of Android sensor programming, tapping into the hardware sensors included in most Android devices (smartphones and tablets). The emphasis of this hour will be on the most common sensor: the accelerometer. We’ll use the code we study in this hour in the next few hours to assist with using other common Android sensors, such as the ambient light sensor, air pressure sensor, and others.

Android Sensors

Android devices may or may not come with all of the sensors supported by OS 4.0. The SDK supports the following types of sensors ...

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