문제

I'm new to android and working on an app that will aggregate sensor data and display it on screen. When I only retrieved accelerometer data, the output was smooth. Now, when I try retrieving gyroscope and lux data as well, the output speed is slower and inconsistent.

Is there a more efficient way of doing this?

// code omitted

EDIT: I've started looking into implementing the retrieval of sensor data as an AsyncTask. But I run into the issue that the OnSensorChanged method would still be part of the UI thread. Is there a way I can avoid this? Is asynctask the way to go?

도움이 되었습니까?

해결책

I seem to have found a solution (for now at least):

Setting the delay for the listeners to SENSOR_DELAY_UI from SENSOR_DELAY_FASTEST has made the output smooth (I know, right?). My guess is that this is due to delays on the thread at such a high polling rate.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top