🚀Quick start
In this part, we will take you through the required basic steps to detect your first trips using DriveKit.
Prerequisites
To complete this quickstart, make sure that your development environment meets the following requirements:
Android Studio (latest version)
An Android 6.0+ device with Play Services
Your Android app must target API level 23 or higher.
Follow the steps described below in your app in order to quickly integrate the DriveKit SDK:
You can also clone the following repository, configure the required credentials then simply run the quickstart app!
Set up your project
The DriveKit SDK is available on the DriveQuant Maven repository.
To access modules in the repository, add the following lines in your Gradle settings appropriate file, according to the structure of your app:
Add the TripAnalysis module to your project
To add the Trip Analysis module to your app, add the following line to your dependencies in your appropriate application build Gradle file:
By adding the TripAnalysis module, it will also add the DriveKit Core module and automatically initialize the DriveKit SDK.
Replace $drivekit_version
with the latest release version of DriveKit on the changelog page.
In some cases you may want to manually initialize the SDK. To do this you have to disable the automatic initialization. Learn more in the Advanced configurations part.
Set the API key
Once you've stored your API key in a secure way in your app, configure DriveKit by calling the following method:
Set a user id
Each driver must be identified with a unique identifier. Once you have this identifier and you are ready to analyze trips, configure DriveKit by calling the following method:
You can call setApiKey()
and setUserId()
methods anywhere in the code. DriveKit will save the value locally. If the app is killed and relaunched, DriveKit will be reconfigured automatically.
We recommend never using an email address or phone number to define the unique user ID. It is recommended that you set up a unique, universal and anonymous user ID. For example, you can generate a globally unique identifier (GUID) for each of your users.
DriveKit SDK will not work until you set the API key and the userId.
Enable the autostart
The automatic mode detects vehicle movements and triggers the trip analysis without driver intervention even if the application is in background. The analysis is stopped automatically at the end of the trip.
This feature is recommended to avoid driver distraction and phone handling while driving. The automatic mode has been optimized to limit the battery drain.
By default, automatic trip detection is disabled, but you can enable it by calling the following method with the activate
parameter to true
:
Runtime permissions
DriveKit requires some runtime permissions to be granted by the user.
To display a simple and intuitive onboarding for the user to grant these runtime permissions, add the dependency for the PermissionsUtils graphical module in your appropriate application build Gradle file:
Replace $drivekitui_version with the latest release version of graphical modules on the changelog page.
Then, call the following code in your project:
Congratulations! You now have an app that will automatically detects every trip you will make.
What's next?
Once your first trips are recorded, fine-tune the DriveKit SDK configuration to fit your needs:
Configure the Core and TripAnalysis modules with advanced settings. For example, customize the notification displayed during a trip analysis,alert the user once a trip has been analyzed by the DriveQuant servers by displaying a notification, activate the crash detection, etc.
Display trip-related data: provide a trip list, a timeline of driver’s score, present the user's driving habits, etc. by integrating the Driver Data module.
Associate each trip to a vehicle that you can configure with the Vehicle module.
Improve user retention by organizing challenges, display ranking with the community, show which badges the driver earned, etc.
Last updated