TripListener
The TripListener
interface provides useful information and event about trips analyzed by DriveKit.
For example, you can be informed when a trip analysis has started, finished, cancelled, when a crash is detected, etc.
Add a TripListener
You can remove a specific listener using the following method:
To remove all TripListeners objects:
If you remove all your trip listeners or forget to add one, your app will not received any feedback from the trip analysis module. It will not prevent the analysis from working but your code will not be able to execute its own logic (UI updates, notification, etc.).
Do not forget to remove your TripListener
objects when you don't need it anymore to prevent memory leaks.
TripListener
interface includes several methods to implement:
Method | Description |
---|---|
tripStarted(startMode: StartMode) | Called each time a trip's started. Possible values are described here. |
tripPoint(tripPoint: TripPoint) | Called when a trip is started and confirmed, for each location point recorded by the SDK. Data available in |
tripSavedForRepost() | Called if at the end of the trip, the trip couldn't be sent to DriveQuant's server for the analysis, for example when the smartphone has no network. The trip is saved locally on the SDK and will automatically be sent later. |
tripFinished(result: TripResult) | This method is called when a trip has been recorded by the SDK and analyzed by the DriveQuant's servers.
|
| This method is called when a trip has been recorded by the SDK and analyzed by the DriveQuant's servers.
Detailed description of these data are available here. |
tripCancelled(cancelTrip: CancelTrip) | This method is called when a trip is cancelled. CancelTrip indicates which event cancels the trip. Possible values are described here. |
beaconDetected() | This method is called when a beacon sets in the SDK is detected. |
sdkStateChanged(state: State) | This method is called every time the state of the SDK changed with the new state as parameter. States are described here. |
onDeviceConfigEvent(deviceConfigEvent: DeviceConfigEvent) | This method is deprecated and will be removed in a future version. It is replaced by the |
crashDetected(crashInfo: DKCrashInfo) | Called when a crash event is detected. Triggered if crash detection is enabled. Read more here |
crashFeedbackSent(crashInfo: DKCrashInfo, feedbackType: DKCrashFeedbackType, severity: DKCrashFeedbackSeverity) | Called when crash feedback is enabled and a confirmed crash is detected. Triggered if Crash Detection is enabled. Read more here |
End of trip notification: Depending on the trip analysis service's response in the tripFinished()
callback, we recommend that you specify the notification content if you decide to display a user feedback:
For a vehicle trip, you can display a message such as:
Your trip has been analyzed
.For a trip by rail it is better to display the following message:
Your trip was made by train.
Get the trip response status (Deprecated)
This method has been deprecated and will be removed at the end of 2025.
The callback method tripFinished(post: PostGeneric, response: PostGenericResponse)
is replaced by tripFinished(result: TripResult)
which directly provides the useful information (see TripResult).
Once the DriveQuant servers has analyzed a trip, the tripFinished()
callback is triggered with the data in the PostGenericResponse
object.
It can be useful to check the trip response status in order to check for example if the trip is valid or not with detailed information.
To do this, call the following method:
The TripResponseStatus model is described in the References part.
Last updated