Background location usage

Android 14 (Android U) introduced new restrictions on apps accessing the user's location in the background. To help mitigate these changes, the Navigation SDK was updated in version 5.3.2 to better manage background location access. We also recommend that you update your implementation to ensure that your app continues to have access to the most precise location data.

How changes in Android 14 impact the Navigation SDK

When you invoke startGuidance() in your app, the foreground service starts showing user notifications for turn-by-turn navigation. Turn-by-turn navigation is dependent on being able to access the user's location in order to update the route and show the correct visual and audio guidance. Starting in Android 14, accessing the user's precise location in the background requires permission from the user. By default, if an app does not have the user's permission for background location access and attempts to start a foreground service for location updates, the system throws a SecurityException, causing the app to crash.

How the Navigation SDK mitigates this issue

Starting with version 5.3.2, the Navigation SDK handles this SecurityException without impacting the app, allowing navigation to continue running in the background. Additionally, the Navigation SDK includes the ACCESS_BACKGROUND_LOCATION permission in its AndroidManifest. This way, your app doesn't need to declare the permission itself, as Gradle merging will handle it. However, if a notification is not displayed to the user before the app goes into the background, the Navigation SDK will rely on the system to provide location updates. These system updates may not be frequent or precise and result in suboptimal navigation experience. For this reason, we recommend that you also prompt users for background location access.

What app developers can do to improve location accuracy for navigation

You can improve the accuracy of the location signal used by the Navigation SDK by updating your app to prompt users for background location access. The prompt should explain to users how granting the permission will improve location accuracy and improve their navigation experience when the app is running in the background.

sample permission

For more information on prompting users for location access, see Request location permissions | Sensors and location | Android Developers.