Vehicle integration basics
Request accessIntroduction
This document explains how an integrator can use the Vehicle Integration Library (VIL) to integrate the Automotive Navigation Application (ANA) with a vehicle. It covers setting up the library, using it, and testing the integration.
Project setup
- Install Android Studio if you don’t already have it.
- To set up VIL, you first need an existing Android project.
- If you don’t have one, follow this guide to create a new Android project .
- Ensure that the minimum SDK API level is set to 27 (Android 8.1 “Oreo”) 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:vehicle-integration-library:0.6.0") ...}Using VIL
Instantiating a Vehicle Integration API Client
Instantiating VIL is typically done on application initialization, where an Android Context is readily available, such as in the onCreate method of your main application class:
Step 1. If you don’t already have an application class, create one (e.g., MyVilApplication) by defining it in a new file named MyVilApplication.kt in your project. Then, initialize VIL as shown below:
import com.tomtom.automotive.integration.vehicle.client.api.VehicleIntegrationApiClientimport com.tomtom.automotive.integration.vehicle.client.api.error.NavAppErrorimport com.tomtom.automotive.integration.vehicle.client.api.status.NavAppConnectionStatusimport com.tomtom.automotive.integration.vehicle.client.api.status.NavAppConnectionStatusTypeimport com.tomtom.automotive.integration.vehicle.client.api.status.StatusCallbackimport com.tomtom.automotive.integration.vehicle.client.lib.VehicleIntegrationApiClientFactory
...
class MyVilApplication : Application() { lateinit var vilClient: VehicleIntegrationApiClient
override fun onCreate() { super.onCreate()
vilClient = VehicleIntegrationApiClientFactory.create( context = this, statusCallback = object : StatusCallback { override fun onConnectionStatus(connectionStatus: NavAppConnectionStatus) { if (connectionStatus.connectionStatusType == NavAppConnectionStatusType.CONNECTED) { // Set parameters } }
override fun onError(error: NavAppError) { // Handle error } } ) }}Step 2. Declare your application class in AndroidManifest.xml:
<application android:name=".MyVilApplication" ... <!-- Other settings --></application>Once VehicleIntegrationApiClient is created (using the VehicleIntegrationApiClientFactory) and the “connected” callback has been received, you can start calling the API functions. The VIL API reference is available in VIL API Reference .
Setting parameter
For instance, you can set the Vehicle Specifications parameter by using the getVehicleInfoManager() function from the VehicleIntegrationApiClient instance:
import com.tomtom.automotive.integration.vehicle.client.api.VehicleIntegrationApiClientimport com.tomtom.automotive.integration.vehicle.client.api.vehicleinfo.vehiclespecs.VehicleSpecsCallbackimport com.tomtom.automotive.integration.vehicle.client.api.vehicleinfo.vehiclespecs.VehicleSpecsFailureimport com.tomtom.automotive.integration.vehicle.client.api.vehicleinfo.vehiclespecs.VehicleSpecsParametersimport com.tomtom.automotive.integration.vehicle.client.api.vehicleinfo.vehiclespecs.VehicleTypeimport com.tomtom.automotive.integration.vehicle.client.lib.VehicleIntegrationApiClientFactoryimport com.tomtom.automotive.integration.vehicle.common.Callbackimport com.tomtom.automotive.integration.vehicle.common.Result
...
vilClient.getVehicleInfoManager().setVehicleSpecs( VehicleSpecsParameters(VehicleType.CAR), object : VehicleSpecsCallback { override fun onResult(result: Result<VehicleSpecsParameters, VehicleSpecsFailure>) { if (result is Result.Failure) { if (result.reason == VehicleSpecsFailure.FAILED_TO_SET_VEHICLE_SPECS) { // Server-side failure to set vehicle specs } else { // Unexpected failure reason } } else { // Vehicle specs set successfully } }
override fun onFunctionalityUnavailable(reason: Callback.Reason) { // Handle functionality unavailable if (reason is Callback.Reason.IncompatibilityError) { // The VIL client is not compatible with the version of the running Navigation Application } } })Required parameters
This section outlines the required parameters your application should set to successfully start ANA. In case not all required parameters are set, the splash screen remains visible in ANA.
To set these parameters, use the respective API functions available in VehicleIntegrationApiClient in the VIL API Reference guide:
VehicleSpecsParameters. Represents a generic vehicle specification, such as the type of vehicle. This data is required for ANA to tailor its behavior and is not expected to change during application runtime. Refer to VIL API Reference for more information.OnlineServicesConfigurationParametersRepresents Online Services configuration information. Refer to VIL API Reference for more information. Specifies a Fully Qualified Domain Name (FQDN), following the format subdomain.domain.tld. The FQDN is required for ANA to understand how to connect to TomTom Online Services. To learn how to acquire an FQDN, refer to Set up online services.OnlineServicesTokenParameters. Includes an authentication token for Online Services in JSON Web Token (JWT) format. A JWT token is required to authenticate and authorize access to TomTom Online Services. The token is dynamic and changes during the lifetime of the application, depending on the expiry timeout of the token. Refer to VIL API Reference for more information. To learn how to set up a JWT token, refer to Set up online services.ResourcesParameters. Represents platform resources accessible to ANA, such as the path to the folder containing onboard map files, keystore, license, and cache. This is required for ANA to understand where to find files related to the onboard map and where it can store related caches. Refer to VIL API Reference for more information.
Error handling
Your application may receive the following error conditions that must be handled appropriately.
| Error | Description | Hints |
|---|---|---|
ErrorCallback.NavAppError.SECURITY_ERROR | The VehicleIntegrationClient has insufficient permissions to establish a connection. | Ensure that your application has the correct Android permissions to use socket communication. |
ErrorCallback.NavAppError.BIND_SERVICE_TIMEOUT | The VehicleIntegrationClient could not establish a connection to the navigation application. | Ensure that the navigation application is installed and running. |
ErrorCallback.NavAppError.EXCEPTION_WHEN_INVOKE_REQUEST | The VehicleIntegrationClient could not complete a request. | This indicates a problem with the navigation application; contact support for assistance. |
ErrorCallback.NavAppError.VERSION_MISMATCH | The VehicleIntegrationClient library version is incompatible with your application. | Ensure that the correct library version is configured for the navigation app version. Check logs for isVersionMismatch. |
ErrorCallback.NavAppError.NO_CONNECTION | The VehicleIntegrationClient is no longer connected to the navigation application. | Ensure that the navigation application is still running. |
Result.Failure.UNHANDLED | The VehicleIntegrationClient library version is incompatible with your application. | Ensure that the correct library version is configured for the navigation app version. |
Callback.Reason.IncompatibilityError | The VehicleIntegrationClient library version is incompatible with your application. | Ensure that the correct library version is configured for the navigation app version. |