android 手机传感器

阅读更多
List sensors = this.sm.getSensorList(Sensor.TYPE_ALL);
StringBuffer str = new StringBuffer();
str.append("该手机有" + sensors.size() + "个传感器,分别是:\n");
Sensor s;
for (int i = 0; i < sensors.size(); i++) {
s = sensors.get(i);
switch (s.getType()) {
case Sensor.TYPE_ACCELEROMETER:
str.append(i + "加速度传感器");
break;
case Sensor.TYPE_GYROSCOPE:
str.append(i + "陀螺仪传感器");
break;
case Sensor.TYPE_LIGHT:
str.append(i + "环境光线传感器");
break;
case Sensor.TYPE_MAGNETIC_FIELD:
str.append(i + "电磁场传感器");
break;
case Sensor.TYPE_ORIENTATION:
str.append(i + "方向传感器");
break;
case Sensor.TYPE_PRESSURE:
str.append(i + "压力传感器");
break;
case Sensor.TYPE_PROXIMITY:
str.append(i + "距离传感器");
break;
case Sensor.TYPE_TEMPERATURE:
str.append(i + "TEMPERATURE-温度传感器");
break;
case Sensor.TYPE_AMBIENT_TEMPERATURE:
str.append(i + "AMBIENT_TEMPERATURE-温度传感器");
break;
case Sensor.TYPE_RELATIVE_HUMIDITY:
str.append(i + "湿度传感器");
break;
case Sensor.TYPE_GAME_ROTATION_VECTOR:
str.append(i + "游戏旋转传感器");
break;
case Sensor.TYPE_ROTATION_VECTOR:
str.append(i + "旋转传感器");
break;
case Sensor.TYPE_SIGNIFICANT_MOTION:
str.append(i + "TYPE_SIGNIFICANT_MOTION");
break;
case Sensor.TYPE_GRAVITY:
str.append(i + "重力传感器");
break;
case Sensor.TYPE_LINEAR_ACCELERATION:
str.append(i + "线性加速度传感器");
break;
case Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED:
str.append(i + "未校准磁场传感器");
break;
default:
str.append(i + "未知传感器");
break;
}
str.append("\n");
str.append("设备名称:" + s.getName() + "\n");
str.append("设备版本:" + s.getVersion() + "\n");
str.append("通用类型号:" + s.getType() + "\n");
str.append("设备商名称:" + s.getVendor() + "\n");
str.append("传感器功耗:" + s.getPower() + "\n");
str.append("传感器分辨率:" + s.getResolution() + "\n");
str.append("传感器最大量程:" + s.getMaximumRange() + "\n");

str.append("===================================\n");
}

LogUtils.d(str.toString());

你可能感兴趣的:(android)