androidaccelerometersensors

Get accelerometer values in time


I have to get the accelerometer values in time. I saw the Sensor class and the SensorEventListener but this listener notify only when the value changes and I need a periodic notification (also if the value do not change). Otherwise I would like to continuously read the accelerometer value but it is not possible according to this thread: Get current SensorEvent value

What can I do?


Solution

  • Why do you need to continuously "read" the sensor values even when they are the same as before? If you need to calculate some output on a regular basis, then a better solution might be to set up a timer that triggers on the required intervals at which time you use the values from a set of variables that are updated whenever the sensor values change. That way even if they don't change, the timer will initiate the calculations.