Android
This section describes how to integrate DriveKit into an Android mobile application.

Requirements

DriveKit is developed with the Kotlin language and is compatible with Android 21 (5.0) and later versions.
The DriveKit SDK requires Google Play Services 16.0.0 or above.

Integration

DriveKit repository

DriveKit SDK are available on DriveQuant Maven repository.
To access modules in the repository, add the following lines to your project build.gradle file:
build.gradle
1
allprojects {
2
repositories {
3
maven {
4
url "https://maven.drivequant.com/repository/android-sdk/"
5
}
6
}
7
}
Copied!

Get module from repository

To add DriveKit Core module to your app, add the following lines to your dependencies in your application build.gradle file:
build.gradle
1
dependencies {
2
implementation 'com.drivequant.drivekit:drivekit-core:$drivekit_version'
3
}
Copied!
Replace $drivekit_version with the DriveKit version you are using in your app

DriveKit initialization

To initialize DriveKit in your app, you must call the initialization method in onCreate method of your application class.
MyApplication.kt
MyApplication.java
1
class MyApplication: Application() {
2
3
override fun onCreate() {
4
super.onCreate()
5
DriveKit.initialize(this)
6
}
7
}
Copied!
1
public class MyApplication extends Application {
2
3
@Override
4
public void onCreate() {
5
super.onCreate();
6
DriveKit.INSTANCE.initialize(this);
7
}
8
}
Copied!
All DriveKit modules include a method initialize that must be called in onCreate method of your application class.

Add API key

To use DriveKit modules, you have to obtain an API Key from DriveQuant. If you don't have an API key, please contact DriveQuant.
Once you've stored your API key in a secure way in your application, you can configure DriveKit by calling the following method:
Kotlin
Java
1
DriveKit.setApiKey("MyAPIKey")
Copied!
1
DriveKit.INSTANCE.setApiKey("MyAPIKey");
Copied!

Identify user

Each driver must be identified with a unique identifier. Once you have this identifier, configure DriveKit by calling the following method:
Kotlin
Java
1
DriveKit.setUserId("MyUserId")
Copied!
1
DriveKit.INSTANCE.setUserId("MyUserId");
Copied!
You can call these 2 configuration methods anywhere in the code. DriveKit will save the value locally. If the app is killed and relaunched, DriveKit will be reconfigured automatically.
DriveKit SDK will not work until you set the API key and the userId.

Check your configuration

You can check if DriveKit is well configured with the following method.
Kotlin
Java
1
DriveKit.isConfigured()
Copied!
1
DriveKit.INSTANCE.isConfigured();
Copied!
This method returns true if DriveKit is well configured.
All DriveKit modules include a method called "isConfigured" that checks the minimum system requirements for each module.

Reset

If you need to reset DriveKit configuration (user logout for example), you can call the following method:
Kotlin
Java
1
DriveKit.reset()
Copied!
1
DriveKit.INSTANCE.reset();
Copied!
All data saved locally by DriveKit will be erased.
All DriverKit modules have reset method that erases all data saved locally by the module.
Make sure that you call reset method of all modules to fully reset DriveKit configuration.

Logging

DriveKit comes with a logging feature that is enabled by default. This feature allows you to quickly identify the cause of a problem. We recommend leaving the log enabled as it does not consume memory space and is useful in the support phase. However, if you don't want to use it, it can be disabled.
You can retrieve the last Uri log file by calling the following method:
Kotlin
Java
1
DriveKitLog.getLogUriFile(context)
Copied!
1
DriveKitLog.INSTANCE.getLogUriFile(context)
Copied!
If your device version is on Android 10 or below, you can directly find the log file in Android/data/<your-app-package-name>/files/<path-to-my-log-directory>
If your device version is on Android 11 and if you have The Permissions Utils component on your app, you can get a log file of the previous month and the current one with the method getZippedLogUriFiles(), or by clicking on “Contact support” and change the email receiver. The file will be in attachment of the email.
Disable logging by calling:
Kotlin
Java
1
DriveKit.disableLogging()
Copied!
1
DriveKit.INSTANCE.disableLogging();
Copied!
To enable logging, call the following method specifying the path of the log directory.
Kotlin
Java
1
DriveKit.enableLogging("/path/to/my/log/directory")
Copied!
1
DriveKit.INSTANCE.enableLogging("/path/to/my/log/directory");
Copied!
Last modified 22d ago