I'm writing a game for Android and want to be able to use the accelerometer for input.
I see two ways of getting a sensor, one way is to use the first element of SensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER)
and the other is SensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
.
The getDefaultSensor
doc says it could return a "composite" sensor, so if I want a "raw" sensor I should use getSensorList
.
Any idea what the difference between a composite or raw sensor is? Does this even apply to the accelerometer? Anyone have experience with devices that contain multiple or composite accelerometers? (Or some other sensor?)
Google's documentation is way ahead of their implementation here. I browsed through the code repository (which seems to be 2.3.1-ish source) and found:
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);
}
So there is no real difference (and I don't think they can really add one later) between the sensors returned from getDefaultSensor()
and from getSensorList()
.