Reputation: 19
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).
Upvotes: 1
Views: 295