Base part sensor type
Motion sensor
These sensors measure acceleration and angle of rotation on three axes (X, Y, Z). Several sensors are included.
Acceleration (accelerometer) sensor
Gyroscope (gyroscope) sensor
Gravity (Gravity) sensor
Linear acceleration (linear acceleration) sensor
Rotation vector (rotational vector) sensor
Environmental sensors
These sensors measure parameters in different environments, such as ambient air temperature and pressure, light intensity and humidity. Several sensors are included.
Temperature (Barometer) sensor
Light (photometer) sensor
Temperature (thermometer) sensor
Pressure (pressure) sensor
Position sensor
This type of sensor can measure the physical location of the device. Several sensors are included.
Direction (orientation) sensor (data from acceleration sensors and magnetic field sensors)
magnetic field (Magnetomenter) sensor
Android Sensor type
Type_accelerometer//Acceleration sensor (hardware)
Type_magnetic_field//magnetic field sensor (hardware)
Type_orientation//Direction sensor (software sensor, data from gravity and magnetic field sensors)
Type_gyroscope//Gyroscope sensor (hardware)
Type_light//light sensor (hardware)
Type_pressure//Pressure sensor (hardware)
Type_proximity//Proximity sensor (hardware)
Type_gravity//heavy-field sensors (hardware or software)
Type_linear_acceleration//Linear acceleration sensor (hardware or software)
Type_rotation_vector//rotational vector sensor (hardware or software)
Type_relative_humidity//humidity sensor (hardware)
Type_ambient_temperature//temperature sensor (hardware)
Type_temperature//temperature sensor (hardware), replaced by Type_ambient_temperature starting from Android4.0
Android Sensor parameters
Sensor Callback Frequency
Parameters |
Delay Time |
Sensormanager.sensor_delay_fastest |
0ms |
Sensormanager.sensor_delay_game |
20ms |
sensormanager.sensor_delay_ui |
60ms |
Sensormanager.sensor_delay_normal |
200ms |
Sensor return value @link
Acceleration Sensing Detection--accelerometer
Accelerometer sensor measures the negative value (including the gravitational acceleration) of the acceleration generated by all forces exerted on the device. The unit used for acceleration is m/sec^2, and the value is the negative value of the acceleration.
SENSOREVENT.VALUES[0]: Negative value of acceleration on X-axis
SENSOREVENT.VALUES[1]: Negative value of acceleration in Y-axis
SENSOREVENT.VALUES[2]: Negative value of acceleration in z-axis
For example:
The acceleration on the x-axis is positive when the phone's z-axis is flat on the desktop and the phone is pushed from left to right.
When the phone's z-axis is stationary on the desktop, the acceleration of the z-axis is +9.81m/sec^2.
When the phone is falling free from the air, the acceleration is 0.
When the cell phone upward with am/sec^2 acceleration to the air, this time the acceleration is a+9.81m/sec^2
Gravitational acceleration Sensing detection--gravity
The gravitational acceleration, whose units are m/sec^2, is consistent with the accelerometer use. When the phone is stationary, the value of the gravity is consistent with the value of the accelerometer.
Linear Acceleration Sensing detection--linear-acceleration
The relationship between Accelerometer, Gravity and Linear-acceleration is as follows:
Accelerometer = Gravity + linear-acceleration
Ground magnetic field sensing detection--magnetic-field
The unit of the geomagnetic field is Micro-tesla (UT), which detects an absolute magnetic field on the X, Y, Z axes.
Gyro Sensing Detection--gyroscope
The gyroscope is in radians per second, measuring the angular velocity of the object rotating around the x, Y, Z axes. Its coordinate system is the same as the acceleration sensor's coordinate system. The angle of rotation counterclockwise is positive. That is, if the device is rotated counterclockwise, the observer will look at the square of the x, Y, Z axis and report that the device is turning. Note that this is the standard mathematical definition of positive rotation.
Light Sensing Detection--light
Values[0]: Indicates the level of ambient illumination, in SI lux units.
Position approximation Sensing detection--proximity
Values[0]: Approximate distance, in cm (cm) units. Some sensors can only support near and far two states, in which case the sensor must report its Maximum_range value in the far state and the small value in the near state.
Rotational vector sensing detects--rotation vectors
The rotation vector is used to represent the direction of the device, which is made up of angles and axes, or the device rotates the θ angle around one of the x, Y, Z axes. The three elements of the rotation vector are so that the size of the rotation vector equals sin (Θ/2), and the direction of the rotation vector equals the direction of the axis of rotation.
Values[0]: X*sin (Θ/2)
VALUES[1]: Y*sin (Θ/2)
VALUES[2]: Z*sin (Θ/2)
VALUES[3]: cos (Θ/2) (optional:only if value.length = 4)
Direction Sensing Detection--orientation
Its unit is angle
Values[0]: Azimuth (azimuth), the angle of the geomagnetic North direction and the Y axis, rotating around the Z axis (0 to 359). 0=north, 90=east, 180=south, 270=west
VALUES[1]: Pitch (pitch), rotating around x-axis ( -180 to 180), positive when z-axis is moving to y-axis
VALUES[2]: Roll (rolling), rotating around the y-axis ( -90 to 90), positive when the x-axis moves to the z-axis
Api:
Get system support sensor type/*** Support Sensor list *http://blog.csdn.net/redoq/article/details/52515123 * https://zhidao.baidu.com/question/2205380242168742428.html * http://www.jianshu.com/p/4c141d851346 */ Private voidtestsupportsensorlist () {Sensormanager Sensormanager=(Sensormanager) Getsystemservice (Sensor_service); String Sensorstr= ""; List<Sensor> list =sensormanager.getsensorlist (Sensor.type_all); for(Sensor sensor:list) {sensorstr+ = Sensor.getname () + "\ n"; } xlog.i (SENSORSTR); Sensorstr= ""; for(Sensor sensor:list) {Switch(Sensor.gettype ()) { CaseSensor.TYPE_ACCELEROMETER:sensorStr+ = "Acceleration sensor" + "\ n"; Break; CaseSensor.TYPE_MAGNETIC_FIELD:sensorStr+ = "magnetic field sensor" + "\ n"; Break; CaseSensor.TYPE_ORIENTATION:sensorStr+ = "Direction sensor" + "\ n"; Break; CaseSensor.TYPE_GYROSCOPE:sensorStr+ = "Gyro sensor" + "\ n"; Break; CaseSensor.TYPE_LIGHT:sensorStr+ = "Light sensor" + "\ n"; Break; CaseSensor.TYPE_PRESSURE:sensorStr+ = "Pressure sensor" + "\ n"; Break; CaseSensor.TYPE_PROXIMITY:sensorStr+ = "Proximity sensor" + "\ n"; Break; CaseSensor.TYPE_GRAVITY:sensorStr+ = "heavy field sensor" + "\ n"; Break; CaseSensor.TYPE_LINEAR_ACCELERATION:sensorStr+ = "linear acceleration sensor" + "\ n"; Break; CaseSensor.TYPE_ROTATION_VECTOR:sensorStr+ = "rotational vector sensor" + "\ n"; CaseSensor.TYPE_RELATIVE_HUMIDITY:sensorStr+ = "Humidity sensor" + "\ n"; Break; CaseSensor.TYPE_AMBIENT_TEMPERATURE:sensorStr+ = "Temperature sensor" + "\ n"; Break; CaseSensor.TYPE_TEMPERATURE:sensorStr+ = "Temperature sensor" + "\ n"; Break; }} xlog.i (SENSORSTR);} The sensor uses the steps (general) S1, before using the sensor to obtain the Sensormanager through the system service get: Sensormanager Msensormanager=(Sensormanager) Getsystemservice (sensor_service); S2, get the type of sensor we need://one-time effective step countSensor Mstepcount =msensormanager.getdefaultsensor (sensor.type_step_counter);//System Count Step cumulative valueSensor Mstepdetector =msensormanager.getdefaultsensor (Sensor.type_step_detector); S3, Register Listener (monitor sensor event) Msensormanager.registerlistener ( This, Mstepdetector, sensormanager.sensor_delay_fastest); Msensormanager.registerlistener ( This, Mstepcount, sensormanager.sensor_delay_fastest); PS: Cancel Registration: Msensormanager.unregisterlistener ( This, Mstepdetector); Msensormanager.unregisterlistener ( This, Mstepcount), S4, implement Sensoreventlistener interface, override method, and get data @override Public voidOnsensorchanged (Sensorevent event)
Reference:
http://blog.csdn.net/mad1989/article/details/20848181
How to get the types of sensors supported by Android devices
Android determines which sensors are supported
Android-about sensors you need to know.
Android Sensor Basics