更新: 他們在棒棒糖更新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源代碼中有更多詳細信息
不再更新。見下文。 –