更新: 他们在棒棒糖更新getDefaultSensor方法,现在是有区别的:
public Sensor getDefaultSensor(int type) {
// TODO: need to be smarter, for now, just return the 1st sensor
List<Sensor> l = getSensorList(type);
boolean wakeUpSensor = false;
// For the following sensor types, return a wake-up sensor. These types are by default
// defined as wake-up sensors. For the rest of the SDK defined sensor types return a
// non_wake-up version.
if (type == Sensor.TYPE_PROXIMITY || type == Sensor.TYPE_SIGNIFICANT_MOTION ||
type == Sensor.TYPE_TILT_DETECTOR || type == Sensor.TYPE_WAKE_GESTURE ||
type == Sensor.TYPE_GLANCE_GESTURE || type == Sensor.TYPE_PICK_UP_GESTURE) {
wakeUpSensor = true;
}
for (Sensor sensor : l) {
if (sensor.isWakeUpSensor() == wakeUpSensor) return sensor;
}
return null;
}
因此,如果有可用的指定类型的多个传感器,getDefaultSensor会返回一个非唤醒版本(除非默认类型是上述那些实际上6定义为唤醒传感器中的一个)
顺便提一下,Sensor.TYPE_TILT_DETECTOR,Sensor.TYPE_WAKE_GESTURE,Sensor.TYPE_GLANCE_GESTURE和Sensor.TYPE_PICK_UP_GESTURE都隐藏在SDK,因为它们旨在仅用于系统UI。 Sensor.java源代码中有更多详细信息
不再更新。见下文。 –