Skip to main content
This guide builds a complete navigation screen: the user taps a destination, the app draws the route, and tapping Go hands off to the full turn-by-turn UI with voice guidance and automatic re-routing.
Turn-by-turn navigation on Android

The finished navigation screen

Before you begin, install the Baato Java client and set up the Navigation SDK. This guide assumes both are in place.

Building the route screen

1

Add the dependency

Specify the required dependency configuration in your app’s build.gradle file.
If you use Mapbox as your map service, the Baato Java client currently supports only the versions pinned above.
2

Add a MapView and apply a Baato style

3

Request location permission and start the location engine

4

Place origin and destination markers

5

Reverse geocode the tapped point

6

Request the route and draw it

7

Forward the activity lifecycle

Launching the navigation UI

Once a route is drawn, hand it to ComponentNavigationHelperActivity as intent extras — Route, origin, destination and lastLocation:
Launching turn-by-turn navigation requires READ_PHONE_STATE when your targetSdkVersion is 30 or above. Declare it in the manifest and request it at runtime, as checkPhoneStatePermission() does above.
The helper activity wires the SDK’s InstructionView, SummaryBottomSheet and navigation listeners together. Its full source is below — copy it as a starting point and adjust the UI to taste.
View on GitHub
View on GitHub

Testing without moving

Walking a route to test navigation gets old fast. MockNavigationActivity replays a route through a fake location engine, so the whole flow runs at your desk. A GPS-mocking app such as Lockito works too, if you would rather drive the system location provider.
Mock navigation along a route

A mocked navigation session

1

Add a MapView to the layout

2

Implement NavigationEventListener and build the options

3

Set the render mode and the replay engine

4

Attach the listeners once navigation is ready

5

Update location and instructions on progress

Launch the mocked session through MockNavigationHelperActivity, passing directionsResponse, origin and lastLocation as intent extras — the same handoff as the real navigation UI, minus the destination.
View on GitHub

Full source

ComponentNavigationActivity

The route screen built in this guide.

MockNavigationActivity

The mocked navigation session.