1

I have the following problem: I want to get acceleration data, even when my phone is in sleep mode, and trigger an event when a threshold is reached.

In the onPause-method I acquire a partial wakelock. For testing purposes I run a countdown timer in the background to check wether the App is still doing work. However approx after 1 minute screen off the sensor stops getting data, but the countdown timer still runs.

Do you know why the sensor activity is killed althoug I have acquired a wakelock and the CPU seems to be running? Do I have to run the sensor in a service?

I am using Android Version 12. This does not happen with older Android versions (e.g. Android 8).

phil3450
  • 19
  • 1
  • Similar topic here: [https://stackoverflow.com/questions/58614272/onsensorchanged-stops-being-called-after-3-minutes-of-locked-screen](https://stackoverflow.com/questions/58614272/onsensorchanged-stops-being-called-after-3-minutes-of-locked-screen) – e07017 Aug 20 '22 at 20:21

0 Answers0