Sensor Introduction
The android sensor framework allows you to access multiple types of sensors. Some sensors are hardware-based and some are software-based. Hardware-based sensors are physical components built in with handheld or flat devices. They obtain data by directly measuring specific environmental properties, such as acceleration, magnetic intensity, or angle changes. Software-based sensors are not physical devices, though they simulate hardware-based sensors. Software-based sensors obtain data from one or more hardware-based sensors that are sometimes called virtual sensors or synthetic sensors. Linear accelerometer and gravity sensor are examples of hardware-based sensors. Table 1 describes the sensors supported by the Android platform.
Few Android devices support all types of sensors. For example, most handheld devices and flat devices have a accelerator and a magnetic sensor, but few have a barometer and a thermometer. A device can also have multiple sensors of the same type. For example, a device can have two Gravity Sensors, each of which has a different measurement range.
Table 1. sensor types supported by the Android platform
Sensor |
Type |
Introduction |
Common scenarios |
Type_accelerometer |
Harderware |
Measure the accelerator force applied to three axes (x, y, z) of the device in the unit of m/s2, including gravity. |
Motion detection (vibration, skew, etc) |
Type_ambient_temperature |
Harderware |
The surrounding temperature is measured in units of degrees Celsius (°C. |
Monitor Air Temperature |
Type_gravity |
Software or Harderware |
The gravity measured in MB/s2 is applied to three axes (x, y, z) of the device. |
Motion detection (vibration, skew, etc) |
Type_gyroscope |
Hardware |
The rotation rate of the device around three physical axes (x, y, z) is measured in radians/s (rad/s ). |
Rotation detection (rotation, flip, etc) |
Type_light |
Hareware |
The surrounding brightness level (illuminance) is measured in lx) |
Control screen brightness |
Type_linear_acceleration |
Software or Harderware |
Measure the acceleration force on three physical axes (x, y, z) of the device in the unit of m/s2, except for gravity. |
Detects the acceleration of a single physical axis. |
Type_magnetic_field |
Hardware |
The magnetic fields of the three physical axes (x, y, z) around the device are measured in units of μ T. |
Create a compass |
Type_orientation |
Software |
The measurement device rotates the angle around three physical axes (x, y, z. After API Level 3, you can combine the gravity sensor and magnetic field sensor with the getrotationmatrix () method to obtain the tilt matrix and rotation matrix. |
Determine the device location |
Type_pressure |
Hardware |
Measure the air pressure in units of HPA or mbar. |
Detect air pressure changes |
Type_proximity |
Hardware |
Measure the distance between an object and the screen of the device in the unit of CM. This sensor is usually used to determine whether a handheld device is taken near a person's ear. |
The location of the phone during the call. |
Type_relative_humidity |
Hardware |
Measure the peripheral relative humidity in percentages (%) |
Monitor Dew Point, absolute and relative humidity. |
Type_rotation_vector |
Software or Harderware |
Provides three elements of the device's rotation vector to measure the device's direction. |
Motion monitoring and rotation monitoring. |
Type_temperature |
Hardware |
The temperature of the device is measured in units of degrees Celsius (°C. This sensor is implemented in various devices and is used in API Level 14 to replace the type_ambient_temperature sensor. |
Monitoring temperature |