Chapter 12

Hardware Sensors

What's in this Chapter?

Using the Sensor Manager

Introducing the available sensor types

Finding a device's natural orientation

Remapping a device's orientation reference frame

Monitoring sensors and interpreting sensor values

Using sensors to monitor a device's movement and orientation

Using sensors to monitor a device's environment

Modern Android devices are much more than simple communications or web browsing platforms. They are now extra-sensory devices that use hardware sensors, including accelerometers, gyroscopes, and barometers, to provide a platform to extend your perceptions.

Sensors that detect physical and environmental properties offer an exciting avenue for innovations that enhance the user experience of mobile applications. The incorporation of an increasingly rich array of sensor hardware in modern devices provides new possibilities for user interaction and application development, including augmented reality, movement-based input, and environmental customizations.

In this chapter you'll be introduced to the sensors currently available in Android and how to use the Sensor Manager to monitor them.

You'll take a closer look at the accelerometer, orientation, and gyroscopic sensors, and use them to determine changes in the device orientation and acceleration, regardless of the natural orientation of the host device. This is particularly useful for creating motion-based user interfaces (UIs).

You'll also explore the environmental sensors, ...

Get Professional Android 4 Application Development, 3rd Edition 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.