> Using the Sensor Manager

> The available sensor-types

> Monitoring sensors and interpreting sensor values

> Using the compass, accelerometer, and orientation sensors

> Remapping your orientation reference frame

> Controlling device vibration

Modern mobile phones are much more than simple communications devices with a connection to the Internet. With microphones, cameras, accelerometers, compasses, temperature gauges, and brightness detectors, smartphones have become extra-sensory devices, able to augment your own perceptions.

Later chapters will explore use of the camera and microphone; in this chapter you will explore the environmental sensors potentially available on Android devices.

Sensors that detect physical and environmental properties offer an exciting innovation for enhancing the user experience of mobile applications. The incorporation of electronic compasses, gravity sensors, brightness gauges, and proximity sensors in modern devices provides an array of new possibilities for interacting with devices, such as augmented reality and physical movement-based input.

In this chapter you'll be introduced to the sensors available in Android and how to use the Sensor Manager to monitor them. You'll take a closer look at the accelerometer and orientation sensors and use them to determine changes in the device orientation and acceleration. This is particularly useful for creating motion-based user interfaces, letting you add new dimensions to your location-based applications.

You'll also learn how to control device vibration to use force feedback in your applications.


The Sensor Manager is used to manage the sensor hardware available on Android devices. Use getSystemService to return a reference to the Sensor Manager Service, as shown in the following snippet:

String service_name = Context.SENSOR_SERVICE;

SensorManager sensorManager = (SensorManager)getSystemService(service_name);

Was this article helpful?

0 0
Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide

Post a comment