android 传感器学习笔记 一

Android库中显示的可支持的传感器类型有三大类(motion sensor,position sensor, environment sensor),共有11种,

motion sensor类:accelerometer(加速器) ,gyroscope(陀螺仪), gravity(重力), linear acceleration(线性加速器), and rotation vector(旋转矢量)。

positon sensor类:geomagnetic field(地磁场) the orientation(方位角) proximity(设备与周围物体距离)。geomagnetic field与 proximity是硬件依赖的,但大部分设备厂商都在硬件上支持此两种传感器,orientation是通过accelerometer and the geomagnetic field 两个传感器数据计算得出,(官方文档中说在api2.2中被取消,有点疑惑,API3以后的便换了一个调用方式)

environment类:light(光线), pressure(压力), temperature(温度), humidity(湿度),所有的environment类传感器都是硬件依赖的,有没有相应的传感器要看设备是否整合进来,但通常一定有Light sensor 以支持屏幕亮度调节。

可以通过代码获取设备中所有的传感器:

private SensorManager mSensorManager;
...
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
List<Sensor> deviceSensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);

猜你喜欢

转载自blog.csdn.net/xiangrufeifei3/article/details/8761931