
DONG NAI UNIVERSITY OF TECHNOLOGY
1
1. Sensors
2. Monitoring
the Battery

DONG NAI UNIVERSITY OF TECHNOLOGY
2
1. Sensors
The emulator does not provide any sensor data. All sensor
testing must be done on a physical device. Alternatively,
OpenIntents.org also provides a handy Sensor Simulator:
http://code.google.com/p/openintents/wiki/SensorSimulator
This tool simulates accelerometer, compass, and
temperature sensors, and it transmits data to the emulator.
Android devices have a variety of sensors :

DONG NAI UNIVERSITY OF TECHNOLOGY
3
1. Sensors
TYPE_ACCELEROMETER: Measures acceleration in three
directions; values are in SI units (m/s2).
TYPE_GYROSCOPE: Measures angular orientation in three
directions; values are angles in degrees.
TYPE_LIGHT: Measures ambient light; values are in SI lux
units.
TYPE_MAGNETIC_FIELD: Measures magnetism in three
directions; the compass values are in micro-Tesla (uT).
TYPE_PRESSURE: Measures barometric pressure.
TYPE_PROXIMITY: Measures the distance to an object;
values are in centimeters, or “near” versus “far.”
TYPE_RELATIVE_HUMIDITY: Measures the relative humidity.
TYPE_AMBIENT_TEMPERATURE: Measures temperature.

DONG NAI UNIVERSITY OF TECHNOLOGY
4
1. Sensors
ØHere are the major classes related to sensor.
Class Comment
Sensor Class representing a sensor. Use
getSensorList(int) to get the list of available
Sensors.
SensorEve
nt
This class represents a Sensor event and
holds informations such as the sensor's type,
the time-stamp, accuracy and of course the
sensor's data.
SensorEventListe
ner An interface: Used for receiving notifications
from the SensorManager when sensor
values have changed.
SensorManag
er
SensorManager lets you access the device's
sensors. Get an instance of this class by
calling Context.getSystemService() with the
argument SENSOR_SERVICE.

DONG NAI UNIVERSITY OF TECHNOLOGY
5
1. Sensors ØWorking with Sensor
üTo get a Sensor, you need to use SensorManager.

