I have a simple application that reads accelerator values (for the x, y, and z axis). But for a certain value, I vibrate my phone programmatically. Thus, whenever vibration occurs, the value of the accelerometer flickers high up and down in range. I want to avoid this. Please let me know how to prevent an accelerometer giving a variable result in vibration mode.
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER)
return;
switch (mDisplay.getRotation()) {
case Surface.ROTATION_0:
x = event.values[0];
y = event.values[1];
break;
case Surface.ROTATION_90:
x = -event.values[1];
y = event.values[0];
Log.i("ROT: ", "90");
break;
case Surface.ROTATION_180:
x = -event.values[0];
y = -event.values[1];
break;
case Surface.ROTATION_270:
x = event.values[1];
y = -event.values[0];
break;
}
}
Thanks.
source
share