2012-03-14 11 views
3

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

回答

1

可以getSensorList获得某种类型的所有传感器但你必须使用你提到的那些methods如果你想要一个特定的传感器。

甚至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); 
} 
第一
相关问题