When using the classic TYPE_ACCELEROMETER sensor, you can do something like:
public void onSensorChanged(SensorEvent sensorEvent){
if (sensorEvent.sensor.getType()==Sensor.TYPE_ACCELEROMETER){
ax=sensorEvent.values[0];
}
}
BUT, when using TYPE_LINEAR_ACCELERATION, how is it supposed to provide the info?
I’ve tried to do things like:
public void onSensorChanged(SensorEvent sensorEvent){
if (sensorEvent.sensor.getType()==Sensor.TYPE_LINEAR_ACCELERATION){
ax=sensorEvent.values[0];
}
}
But it’s not working. I’ve seen the post
Android TYPE_LINEAR_ACCELERATION sensor – what does it show?
And also I’ve looked the official documentation:
Sensor and
SensorEvent
Which are very interesting indeed, but don’t talk about how they took the samples. Any Idea?
Ok, it’s with
It was MY fault, because I didn’t register the listener properly.
So, In conclussion:
TYPE_LINEAR_ACCELERATIONis used like the tradiotionalTYPE_ACCELEROMETER