Android Background Policies#
Location Permissions#
The app needs permission from the OS to access the device location. Location data is monitored continuously during a protection session but also used during an emergency to send the real-time user’s location to emergency services.
The SDK requires the “Always allow” location permission from Android version 10 and higher. The “When in use” permission is NOT sufficient, it does not allow access to location data when the user is not interacting with your app.
Google PlayStore Review#
Access to background locations needs to be approved by Google Play when submitting your app. This has been required by Google since April 2022. You’ll find further details in the Play Console Help.
This should not pose any significant difficulty since accident detection is a legitimate use case. We can help you with this process and help you answer the Google Play Console declaration form if you need.
Background Processing#
An app can be considered by Android as being in the background for a variety of reasons (ex: the phone is locked or the user switched to another app) which can restrict the processing it can do (ex: monitoring sensor data). For accident detection to work reliably your app needs to be considered “foreground” after calling startProtection()
, in order for the SDK to analyze sensor data continuously.
Notification for Foreground Service#
To be considered as “foreground” on Android version 8 and higher, the app needs to have an Android Service bound to an Android Notification. The SDK takes care of that automatically between startProtection()
and stopProtection()
. The notification that is shown to the user can be configured as an optional parameter to startProtection()
. Its text should explain that processing is happening.
For instance:
Title: Protection running
Subtitle: Click to show your trip
The notification text should be updated when the alarm sound and vibration start, to show what happens and help the user cancel the alert countdown.
Ignoring Battery Optimizations (optional)#
In some power saving modes, Android can kill applications despite their foreground service. Your app can request to be exempted from these restrictions to continue protecting users.
This is optional and requires an additional permission:
android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
.
Learn more in the Android developers documentation.
Survive to a Crash or a Kill#
Despite all the previous precautions there is still a possibility that the app crashed or is killed by Android (eg: to preserve memory when too many applications are active).
This would be damaging when an emergency is ongoing. In this case, when the app restarts, the SDK will resume automatically to complete these tasks:
Emergency sending
Post-accident location tracking