Android background setup
Start with the foreground setup, then add only the declarations required by the background features your product enables. Android permission prompts must be requested in stages; declarations alone do not grant access.
Feature-to-permission map
The library manifest contributes its service/receiver infrastructure and the foreground-service, activity, boot, and wake-lock declarations. Your merged app manifest must still contain the foreground/background location and Android 13+ notification declarations used by your configuration.
If the app does not use optional background features, inspect the merged
manifest and remove inherited optional declarations with manifest-merger
tools:node="remove" rules as described in
Privacy and Compliance.
Minimum continuous-tracking declarations
Use this set only when the app actually starts continuous background tracking:
The library's merged manifest supplies:
Do not add ACTIVITY_RECOGNITION behavior unless you use standalone activity
events or trackingMode: 'activityAware'. Do not enable startOnBoot merely
because the library declares the boot receiver.
Request in a user-understandable sequence
- Explain and request foreground location while the user is using the feature.
- Show the feature working in the foreground.
- Explain why the specific product outcome needs access when the app is not active, then request background access.
- On Android 13+, request notification permission before starting continuous tracking and explain the persistent tracking notification.
- Request Activity Recognition only when enabling activity-aware behavior.
Continue to Background permissions for the API flow. Never loop a denied prompt or open settings without a user action and explanation.
Verify the setup
After native generation and manifest merging:
Inspect android/app/build/intermediates/merged_manifests (the exact Gradle path
can vary) to confirm that enabled capabilities are present and unused optional
capabilities are removed. Then test foreground grant, background grant, denied,
notification-denied, swipe-away, and reboot behavior on the Android versions and
OEMs you ship. The reliability contract defines what
the library can and cannot guarantee.
