Quickstart

VERSION 0.3.34
PUBLIC PREVIEW

Navigation SDK for Android is only available upon request. Contact us to get started.

The Navigation SDK provides a set of tools that allows you to bring a complete navigation experience to your application. It offers two modes of navigation: turn-by-turn navigation and free driving mode. In this guide you will see how to set up the project to deploy basic navigation features on your emulator or device.

Project set up

  1. Get your TomTom API key from the Developer Portal. You can find instructions on how to do that here.
  2. Configure the project as described in the Project setup guide.
  3. Add the Navigation module dependency in the build.gradle of your application module and synchronize the project.
    1dependencies {
    2 def version = "0.3.34"
    3 implementation "com.tomtom.sdk:navigation:$version"
    4}

Creating the TomTomNavigation object

Once the Navigation SDK is added to the application, you can start creating navigation. To do so use the NavigationConfiguration.Builder to create an instance of NavigationConfiguration. It requires 4 parameters:

  • context - to initialize Android dependencies.
  • navigationApiKey - the TomTom API key.
  • locationEngine - the LocationEngine used by navigation to receive user location updates. This must be the MapMatchedLocationEngine for navigation to function. Read more about it in the location updates guide.
  • routingApi - the RoutingApi that will be used for replanning the route.
1val locationEngine = GmsLocationEngine(this)
2val routingApi = OnlineRoutingApi.create(this, "YOUR_API_KEY")
3val guidanceEngine = GuidanceEngineFactory.createGuidanceEngine(
4 this,
5 GuidanceEngineOptions(units = Units.METRIC)
6)
7val navigationConfiguration = NavigationConfiguration.Builder(
8 context = applicationContext,
9 navigationApiKey = "YOUR_API_KEY",
10 locationEngine = locationEngine,
11 routingApi = routingApi
12)
13 .guidanceEngine(guidanceEngine)
14 .build()

If NavigationConfiguration is initialized, you can create the TomTomNavigation object. It is responsible for interacting with and customizing navigation. TomTomNavigation is used to:

  • Start navigation.
  • Stop navigation.
  • Update route plan.
  • Get an instance or replace engines.
  • Set and remove different action listeners.
val navigation = TomTomNavigation.create(navigationConfiguration)

Starting navigation

Call the TomTomNavigation.start() method to start processing data.

tomTomNavigation.start()

Once you start the navigation session, TomTomNavigation will:

  1. Request locations from the map-matched LocationEngine.
  2. Process the incoming locations and send out various events with modified data, such as map matched locations.
  3. Send out guidance events once navigation has started with the route.

More details how to use the navigation can be found in the Turn-by-turn and Free driving guides.

center