The Navigation SDK will display default Android system notifications to keep your users updated on navigation status. The SDK also contains code to customize and display system notifications.
By default, the SDK automatically displays a notification when free-drive mode is enabled and when a turn-by-turn navigation session begins. The notification appears in the device's notification drawer and an arrow icon is added to the status bar. Tapping on the notification brings back the application to the foreground.
A Navigation SDK turn-by-turn navigation session displays default notifications including:
- The upcoming maneuver icon
- Text with the name of the upcoming maneuver
- The distance remaining until the upcoming maneuver
- The ETA of the active route
- A button to end navigation
The Navigation SDK's free drive mode displays a default notification that includes:
- Text saying
Free Drivein whatever language the Navigation SDK is using
- A button to stop the free drive session.
If you app targets Android 13 or higher, we recommend requesting
POST_NOTIFICATIONS permission in runtime so that the Navigation SDK can display the trip notification. The permission declaration is pre-bundled with Navigation SDK v2.8.0 or later.
No system notifications
By default, the Navigation SDK will run a foreground service to render location updates and notification. But, you can customize the default behavior by setting
false when starting the trip session to prevent a foreground service from being started. In this case, no notifications will be rendered and no location updates will be available while the app is in the background.
Do the following when you start the trip session in your activity:
mapboxNavigation.startTripSession(withForegroundService = false)
Custom system notifications
The default notification will always be displayed by default unless trip session is started
withForegroundService = false or it is otherwise overridden by a custom notification created using the Navigation SDK's
TripNotification interface. The interface defines a contract for the Android system
Notification instance provider and manager.
Learn how to leverage the Mapbox Navigation SDK for Android modularization options in the Testing and development guide.