I am recording sensors (Acceleration, Magnetometer, Gyro) on Android during running and walking. Sensors are registered with a sample rate of 50ms (20 values per seconds) with #SensorManager#registerListener.
The first issue I have is that the values are sent about every 2ms, but according to the documentation, the rate is just a hint.
But the real problem is, that when the application is running in background with foreground services and screen locked, that at some points no sensors are received for a certain amount of time (5-50 seconds). This varies across different devices. The following image shows the gaps related to the data index to get a better feeling of the problem.
[
I guess that this is somehow related to power management of the devices, but I cannot find any documentation or even solution for that. Every help is appreciated.
question from:
https://stackoverflow.com/questions/65879105/android-sensoreventlistener-timeout-in-background 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…