I am trying to measure angle at which my phone is using accelerometer. I refer to the method demonstrated here. But the problem is that when I rotate my phone at a high speed, it skips readings. For example, if I rotate my phone from 0
degrees to 90
degrees within a second, I get readings in logcat as : 0, 50, 90
. What I really want is to obtain all the values through which the phone has rotated, like 0,1,2,...,90
. Is it possible? If yes, what am I missing? Do I need to use gyroscope/magnetometer as well?
Asked
Active
Viewed 37 times
1

Community
- 1
- 1

androidnoob
- 345
- 2
- 17
1 Answers
0
Basically it was the sensor delay which was causing the issue. I resolved it by setting the delay to SensorManager.SENSOR_DELAY_FASTEST
.

androidnoob
- 345
- 2
- 17
-
Be aware that SensorManager.SENSOR_DELAY_FASTEST is arbitrary depending on the device. For some devices it is 50Hz and on others it can be upwards of 300Hz.... – Kaleb Feb 24 '16 at 14:50
-
@Kaleb Thanks for the heads up :) . However, I am using a delay value (45000) which is not defined in the SensorManager class. Do you think that might cause any issues? – androidnoob Feb 24 '16 at 15:51
-
That is about 22Hz and I have never come across a device that couldn't do at least 22Hz (you never know). Also, defining a delay is Android 2.3+. – Kaleb Feb 24 '16 at 16:04
-
That means I'm on a safer side. I'm targeting API 15 as minimum. Thanks a lot though. – androidnoob Feb 24 '16 at 16:20