1

My project requires that an android application be able to collect accelerometer and gyroscope data and perform some calculations. It works while the screen is on, but as soon as the screen turns off, all data stops printing in my logcat.

I've read the "Best Practices for Accessing and Using Sensors" in the android documentation (https://developer.android.com/guide/topics/sensors/sensors_overview#sensors-practices). I know of the WakeLock solution. I was wondering if a solution exist where I can still collect data and perform calculations while the screen is off - not use the WakeLock solution. I've looked into services but I don't know if it will work.

Mob
  • 11
  • 2
  • Without a wakelock, your code will not run, because the CPU will stop executing instructions. Beyond that, the policies for background sensor access vary by OS version and, at least on older devices, by device manufacturer. – CommonsWare Jun 17 '22 at 22:52

0 Answers0