3

Android 的 SensorManager 类将返回指定类型的传感器列表。我想知道一个设备是否有,例如,多个内部温度传感器(TYPE_AMBIENT_TEMPERATURE),我该如何区分它们?Sensor.getName() 和 Sensor.getVendor() 会是我必须使用的全部吗?

4

1 回答 1

1

您可以getSensorList访问某种类型的所有传感器,但是如果您想要某个传感器,则必须使用您提到的那些方法。

甚至执行getDefaultSensor只返回列表中的第一个

public Sensor getDefaultSensor(int type) {
     // TODO: need to be smarter, for now, just return the 1st sensor
     List<Sensor> l = getSensorList(type);
     return l.isEmpty() ? null : l.get(0);
}
于 2012-03-14T23:51:02.493 回答