page.title=Sensors @jd:body

Topics

  1. Sensors Overview
  2. Motion Sensors
  3. Position Sensors
  4. Environment Sensors

Key classes and interfaces

  1. {@link android.hardware.Sensor}
  2. {@link android.hardware.SensorEvent}
  3. {@link android.hardware.SensorManager}
  4. {@link android.hardware.SensorEventListener}

Related samples

  1. Accelerometer Play
  2. API Demos (OS - RotationVectorDemo)
  3. API Demos (OS - Sensors)

Most Android-powered devices have built-in sensors that measure motion, orientation, and various environmental conditions. These sensors are capable of providing raw data with high precision and accuracy, and are useful if you want to monitor three-dimensional device movement or positioning, or you want to monitor changes in the ambient environment near a device. For example, a game might track readings from a device's gravity sensor to infer complex user gestures and motions, such as tilt, shake, rotation, or swing. Likewise, a weather application might use a device's temperature sensor and humidity sensor to calculate and report the dewpoint, or a travel application might use the geomagnetic field sensor and accelerometer to report a compass bearing.

The Android platform supports four broad categories of sensors:

To access these sensors, you can use the Android sensor framework. The sensor framework provides several classes and interfaces that help you perform a wide variety of sensor-related tasks. To learn more about the framework and the sensors that are supported on the Android system, read the following documents:

Sensors Overview
Learn how to list the sensors that are on a device, set up sensor event listeners, and acquire sensor data. Also learn best practices for accessing and using sensors.
Motion Sensors
Learn how to use the sensors that provide acceleration data, such as the accelerometer, gravity sensor, and linear acceleration sensor. Also learn how to use the sensors that provide rotational data, such as gyroscopes and rotational vector sensors.
Position Sensors
Learn how to use the sensors that provide orientation and compass data, such as the orientation sensor and the geomagnetic field sensor.
Environment Sensors
Learn how to use the sensors that provide environmental data, such as the light, humidity, pressure, temperature, and proximity sensors.