With Android P, apps running in the background will no longer receive sensor updates. One way around this will be using a Foreground Service.
According to this
Limited access to sensors in background
Android P limits the ability for background apps to access user input and sensor data. If your app is running in the background on a device running Android P, the system applies the following restrictions to your app:
-
Your app cannot access the microphone or camera.
-
Sensors that use the continuous reporting mode, such as accelerometers and gyroscopes, don't receive events.
-
Sensors that use the on-change or one-shot reporting modes don't receive events.
If your app needs to detect sensor events on devices running Android P, use a foreground service.
Does this also apply to indirect sensor access like through the Awareness/Fence API? Do they need a foreground service as well?