'How to read only once from Android build in Accelerometer per second?
With help of sensorManager I am reading accelerometer reading. Currently slowest setting ie SENSOR_DELEY_NORMAL ,accelerometer reads around 10 times every second. Is there any way by which it can reduce sending reading , may be once every second.
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
Sensor mySensor = sensorEvent.sensor;
if (mySensor.getType() == Sensor.TYPE_ACCELEROMETER) {
x = sensorEvent.values[0];
y = sensorEvent.values[1];
z = sensorEvent.values[2];
rootSquare = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
//it reads every second 10 times ie 200 millisecon
}
@Override
protected void onResume() {
super.onResume();
sensorManager.registerListener(this, accelorometer, SensorManager.SENSOR_DELAY_NORMAL);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
