Get started

Prerequisite

Before starting DriveKit Driver Data integration, make sure that you have initialized DriveKit.

Integration

Get module from repository

To add Driver Data module to your app, add the following line to your dependencies in your application build.gradle file:
1
dependencies {
2
implementation 'com.drivequant.drivekit:drivekit-driver-data:1.13.0'
3
}
Copied!

Initialization

An initialization phase is required to use the functions offered by the Driver Data component. To initialize Driver Data component in your app, you must call the initialization method in onCreate method of your application class.
Kotlin
Java
1
DriveKitDriverData.initialize()
Copied!
1
DriveKitDriverData.INSTANCE.initialize();
Copied!

Check your configuration

You can check if Driver Data component is well configured with the following method:
Kotlin
Java
1
DriveKitDriverData.isConfigured()
Copied!
1
DriveKitDriverData.INSTANCE.isConfigured();
Copied!
This method returns true if it is well configured.

Get driver trips

To get Driver trips, you have to call the following method:
1
fun getTripsOrderByDateDesc(listener: TripsQueryListener, type : SynchronizationType = SynchronizationType.DEFAULT)
Copied!
SynchronizationType can have 2 values:
    DEFAULT: if this value is used, the SDK will try to synchronize local trips with DriveQuant backend to get new trips or modified trips, and then return the trip list via the completionHandler.
    CACHE: if this value is used, no synchronization will be performed and only trips previously synchronized will be return via the completionHandler.
An implementation of TripsQueryListener must be provided in order to retrieve trips.
1
interface TripsQueryListener {
2
fun onResponse(status: TripsSyncStatus, trips: List<Trip>)
3
}
Copied!
The status in onResponse have one of the following values:
    NO_ERROR: Synchronization has been successfully performed.
    CACHE_DATA_ONLY: SynchronizationType has been set to CACHE.
    FAILED_TO_SYNC_TRIPS: Synchronization has failed, only trips previously synchronized are returned.
Trips are returned and sorted by end date in descending order.
Example:
1
DriveKitDriverData.getTripsOrderByDateDesc(object: TripsQueryListener {
2
override fun onResponse(status: TripsSyncStatus, trips: List<Trip>) {
3
// Check status and trips data
4
}
5
}, SynchronizationType.DEFAULT)
Copied!

Get specific trip

To get a specific trip, you have to call the following method:
1
fun getTrip(itinId: String, listener: TripQueryListener)
Copied!
The itinId parameter is the unique identifier for a trip.
An implementation of TripQueryListener must be provided in order to retrieve the trip.
1
interface TripQueryListener {
2
fun onResponse(status: TripsSyncStatus, trip: Trip?)
3
}
Copied!
When you call this method, you will get trip data and trip safety events. If safety events are not synchronized locally for the trip, a synchronization with DriveQuant backend will be performed and then, the trip will be returned with safety events synchronized.
TripSyncStatus can have the same value as above and the value FAILED_TO_SYNC_SAFETY_EVENTS if the safety events synchronization failed.
Example:
1
DriveKitDriverData.getTrip(itinId, object: TripQueryListener {
2
override fun onResponse(status: TripsSyncStatus, trip: Trip?) {
3
// Check status and use trip data
4
}
5
})
Copied!

Get trip road data

To get road data of the trip (latitude, longitude), you have to call the following method:
1
fun getRoute(itinId: String, listener: RouteQueryListener)
Copied!
An implementation of RouteQueryListener must be provided in order to retrieve the trip.
1
interface RouteQueryListener {
2
fun onResponse(status: RouteStatus, route: Route?)
3
}
Copied!
RouteStatus can have 2 values:
    NO_ERROR: The trip has been successfully retrieved.
    FAILED_TO_RETRIEVE_ROUTE: Route has not been synchronized. route parameter will be null.
Example:
1
DriveKitDriverData.getRoute(itinId, object: RouteQueryListener {
2
override fun onResponse(status: RouteStatus, route: Route?) {
3
// Check status and use route data
4
}
5
})
Copied!

Delete a trip

To delete a trip, you have to call the following method:
1
fun deleteTrip(itinId: String, listener: TripDeleteQueryListener)
Copied!
The itinId parameter is the unique identifier for a trip.
Example:
1
DriveKitDriverData.deleteTrip(itinId, object: TripDeleteQueryListener {
2
override fun onResponse(status: Boolean) {
3
if (status) {
4
//Trip succesfully deleted
5
} else {
6
// Failed to delete trip
7
}
8
}
9
})
Copied!

Get driver synthesis

To get driver synthesis data, you have to call the following method:
1
fun getSynthesis(
2
listener: SynthesisQueryListener,
3
synchronizationType: SynchronizationType)
Copied!
An implementation of SynthesisQueryListener must be provided in order to retrieve synthesis data.
1
interface SynthesisQueryListener {
2
fun onResponse(synthesisStatus: SynthesisStatus, synthesis: Synthesis?)
3
}
Copied!
SynthesisStatus in the callback can have 3 values:
    NO_ERROR: Synchronization has been successfully performed.
    CACHE_DATA_ONLY: SynchronizationType has been set to cache.
    FAILED_TO_SYNC_SYNTHESIS_CACHE_ONLY: Synchronization has failed, only data retrieved during the last synchronisation are returned.
Example:
Kotlin
Java
1
DriveKitDriverData.getSynthesis(object : SynthesisQueryListener {
2
override fun onResponse(
3
synthesisStatus: SynthesisStatus,
4
synthesis:Synthesis?) {
5
// Check synthesisStatus and use synthesis data
6
}
7
})
Copied!
1
DriveKitDriverData.INSTANCE.getSynthesis(new SynthesisQueryListener() {
2
@Override
3
public void onResponse(@NotNull SynthesisStatus synthesisStatus, @Nullable Synthesis synthesis) {
4
// Check synthesisStatus and use synthesis data
5
}
6
}, SynchronizationType.DEFAULT);
Copied!

Get driver timelines

To get driver timelines, you have to call the following method:
1
fun getTimelines(
2
periods: List<DKTimelinePeriod>,
3
listener: TimelineQueryListener,
4
synchronizationType: SynchronizationType)
Copied!
periods attribute helps you get timeline data in a specific period of time.
The DKTimelinePeriod enum values are:
    WEEK
    MONTH
An implementation of TimelineQueryListener must be provided in order to retrieve timeline data.
1
interface TimelineQueryListener {
2
fun onResponse(timelineSyncStatus: TimelineSyncStatus,
3
timelines: List<Timeline>)
4
}
Copied!
TimelineSyncStatus in the callback can have 4 values:
    NO_ERROR: Synchronization has been successfully performed.
    CACHE_DATA_ONLY: SynchronizationType has been set to cache.
    FAILED_TO_SYNC_TIMELINE_CACHE_ONLY: Synchronization has failed, only data retrieved during the last synchronisation are returned.
    NO_TIMELINE_YET: Synchronization has been successfully performed and there is currently no timeline.

Reset

If you need to reset Driver Data configuration (user logout for example), you can call the following method:
Kotlin
Java
1
DriveKitDriverData.reset()
Copied!
1
DriveKitDriverData.INSTANCE.reset()
Copied!
All data saved locally by DriverData component will be erased and default configuration will be restored.
Last modified 1mo ago