質問

There is an onSensorChanged(SensorEvent event) listener for android sensor. But this is triggered whenever this is a tiny change in the sensor data. How can I check the sensor reading every 0.5s instead of whenever the sensor data has changed?

役に立ちましたか?

解決

I'm afraid you can not set the interval that the callback will be triggered since even passing SensorManager.SENSOR_DELAY_NORMAL parameter will cause it to trigger more than once every half second. Check the values for SENSOR_DELAY below.

SENSOR_DELAY_UI (60,000 microsecond delay)

SENSOR_DELAY_FASTEST (0 microsecond delay)

SENSOR_DELAY_NORMAL) (200,000 microseconds delay)

So, you will receive callbacks every 0.2 seconds and implement your way to DoYourProcedure() once every 2.5 ticks.

他のヒント

use Handler.postDelay(runnable, timeInMillis)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top