case Sensor.TYPE_MAGNETIC_FIELD:
txt.setText(txt.getText().toString() + s.getType()
+ " 电磁场传感器magnetic field" + tempString);
break;
case Sensor.TYPE_ORIENTATION:
txt.setText(txt.getText().toString() + s.getType()
+ " 方向传感器orientation" + tempString);
break;
case Sensor.TYPE_PRESSURE:
txt.setText(txt.getText().toString() + s.getType()
+ " 压力传感器pressure" + tempString);
break;
case Sensor.TYPE_PROXIMITY:
txt.setText(txt.getText().toString() + s.getType()
+ " 距离传感器proximity" + tempString);
break;
case Sensor.TYPE_RELATIVE_HUMIDITY:
txt.setText(txt.getText().toString() + s.getType()
+ " 湿度传感器relative_humidity" + tempString);
break;
case Sensor.TYPE_ROTATION_VECTOR:
txt.setText(txt.getText().toString() + s.getType()
+ " 旋转矢量传感器rotation_vector" + tempString);
break;
case Sensor.TYPE_TEMPERATURE:
txt.setText(txt.getText().toString() + s.getType()
+ " 温度传感器temperature" + tempString);
break;
default:
txt.setText(txt.getText().toString() + s.getType() + " 未知传感器"
+ tempString);
break;
}
}
}
}
以上代码在android4.0环境下编写的,可以获取到所有类型的传感器TYPE,经测试,我的破测试机只有如下三个传感器,比较悲剧的低端机: