Search code examples
androidsensorsandroid-sensors

Getting sensor values per second


Is there any way that I can get the sensor reading per second? what is SENSOR_DELAY_NORMAL rate in seconds?

sm=(SensorManager)getSystemService(SENSOR_SERVICE);
accelerometer=sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
sm.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL);

Solution

  • The delay specified by SENSOR_DELAY_* is only a suggested delay, actual results might come faster or slower. If you only need one reading per second you can use the slowest rate (SENSOR_DELAY_NORMAL), it should update about 5 times per second. You'll need your own timing if you want to do something exactly once per second, though.

    http://developer.android.com/guide/topics/sensors/sensors_overview.html