Automotive Navigation Application

Getting started

Request access

Introduction

This document explains how an integrator can use the Client Integration Library (CIL) to interface and control the Automotive Navigation Application (ANA). It covers setting up the library and using the library.

Note:
The public release of this library will begin with v0.8, which is not yet available. If you are using an earlier version, you may request access to the private preview. Please reach out to your contact person to obtain access.

Project setup

  • Install Android Studio if you don’t already have it.
  • To set up CIL, you first need an existing Android project.
  • Ensure that the minimum SDK API level is set to 31 (Android 12 “S”) or higher.
  • Ensure that the minimum Kotlin version used is 1.9.25 or higher.

Configuring project dependencies

Step 1. Add the Artifactory repository URL to the repositories block (settings.gradle.kts):

dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
url = uri("https://repositories.tomtom.com/artifactory/automotive-maven-release")
credentials {
username = "your-username" // Replace with your Artifactory username
password = "your-password" // Replace with your Artifactory password
}
}
}
}

Step 2. Update your app-level Gradle file (for example, app/build.gradle.kts) to include the maven package as a dependency.

dependencies {
implementation("com.tomtom.automotive:client-integration-library:0.8.0")
...
}

Using CIL

Instantiating the NavAppClient

To use the Client Integration Library, you need to create an instance of NavAppClient, using the NavAppClientFactory().create(Context, ErrorCallback) method. The returned instance is used to access the individual APIs. As instantiating the NavAppClient requires some background initialization, it’s best to create the NavAppClient once per application, e.g. in the Activity onCreate callback. Once this call returns, the NavAppClient instance is ready to use.

Multiple applications can connect to the CIL simultaneously, each with their own NavAppClient instance.

Note:
If any error occurs and a callback to ErrorCallback is received, the NavAppClient instance can no longer be used. Any outstanding calls are lost and any subsequent calls are no-ops.

override fun onCreate() {
super.onCreate()
// Instantiate the NavAppClient passing in a Context and an ErrorCallback.
navAppClient = NavAppClientFactory().create(this, object : ErrorCallback {
override fun onError(error: NavAppError) {
// Handle error
}
})
}

And closed in the Activity onDestroy callback, using NavAppClient close() method.

override fun onDestroy() {
// Clean up when activity is destroyed
navAppClient.close()
super.onDestroy()
}

In case the NavAppClient instance is used in some other components (eg. ViewModels, Singleton, etc.), make sure the close() method is called at some point when it doesn’t need to be used anymore, to prevent leaking the service connection.

Accessing the APIs

After creation, the NavAppClient instance can be used to access the APIs. Note that all callbacks from the SDK are done on the UI Thread.

Example of planning a trip:

val currentPositionManager = navAppClient.getCurrentPositionManager()
val observePositionReleasable = currentPositionManager.observeCurrentPosition(object : CurrentPositionListener {
override fun onCurrentPosition(info: CurrentPositionInfo) {
// Handle current position update
}
override fun onFunctionalityUnavailable(reason: Callback.Reason) {
// Handle functionality unavailable
}
})