Search code examples
javaandroidwearables

Service killed if sensor updates (too) slowly


I have a sensor event listener implemented in a Service which works fine as long as the sampling period and max report latency is under 1s, but as soon as I increase the sampling period over 1s the sensor wont update at all.

I want the sampling period to be 10s possibly 30s as the app I'm developing will need the rotation vector data over extended periods of time (5-10h) and I'm trying to save as much battery life on a smartwatch as possible.

I'll happily provide more information if I wasn't clear enough,

Thank you in advance!


Solution

  • So I found the problem and apparently it's the device's hardware limitations. You can find the max delay by calling sensor.getMaxDelay. If the delay is set to any higher the sensors delay will be set to that. However on older devices it may or may not work. Link to android docs

    It seems that if you want a sensor slower than the max delay you'll have to implement some type of runnable or thread.