TripListener
Last updated
Was this helpful?
Last updated
Was this helpful?
The TripListener
interface provides useful information and events about trips analyzed by DriveKit.
For example, you can be informed when a trip analysis has started, finished, canceled, when a crash is detected, etc.
You can remove a specific listener using the following method:
To remove all TripListeners objects:
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:
tripRecordingStarted(state: DKTripRecordingStartedState)
Immediately called when a trip recording starts.
This callback is triggered:
after automatic trip detection.
tripRecordingConfirmed(state: DKTripRecordingConfirmedState)
tripRecordingCanceled(state: DKTripRecordingCanceledState)
Called when a trip recording is canceled. DKTripRecordingCanceledState
indicates which event has canceled the trip.
tripRecordingFinished(state: DKTripRecordingFinishedState)
tripFinished(result: TripResult)
This method is called when a trip has been recorded by the SDK and analyzed by the DriveQuant's servers.
tripPoint(tripPoint: TripPoint)
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.
beaconDetected()
This method is called when a beacon sets in the SDK is detected.
sdkStateChanged(state: State)
crashDetected(crashInfo: DKCrashInfo)
crashFeedbackSent(crashInfo: DKCrashInfo, feedbackType: DKCrashFeedbackType, severity: DKCrashFeedbackSeverity)
Called each time a trip has started and is confirmed. StartMode
indicates which event starts the trip.
tripFinished(post: PostGeneric, response: PostGenericResponse)
This method is called when a trip has been recorded by the SDK and analyzed by the DriveQuant's servers.
PostGeneric
contains raw data sent to DriveQuant's server, PostGenericResponse
object contains the trip analysis made on DriveQuant's server.
onDeviceConfigEvent(deviceConfigEvent: DeviceConfigEvent)
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.
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:
after calling the DriveKit SDK's method.
DKTripRecordingStartedState
object is described .
Called each time a trip is confirmed.
DKTripRecordingConfirmedState
object is described .
DKTripRecordingCanceledState
object is described .
Called when trip recording has ended, before sending trip data to DriveQuant's servers.
DKTripRecordingFinishedState
object is described .
object contains the trip analysis result made on DriveQuant's server.
Called when a trip is started and confirmed, for each location point recorded by the SDK. Data available in TripPoint
object are described .
This method is called every time the state of the SDK changed with the new state as parameter. States are described .
Called when a crash event is detected. Triggered if crash detection is enabled. Read more
Called when crash feedback is enabled and a confirmed crash is detected. Triggered if Crash Detection is enabled. Read more
tripStarted(startMode: StartMode)
This method has been deprecated to be replaced by: tripRecordingConfirmed(state: DKTripRecordingConfirmedState)
Possible values are described .
tripCancelled(cancelTrip: CancelTrip)
This method has been deprecated to be replaced by: tripRecordingCanceled(state: DKTripRecordingCanceledState)
This method is called when a trip is cancelled. CancelTrip indicates which event cancels the trip. Possible values are described .
This method has been deprecated to be replaced by: tripFinished(result: TripResult)
Detailed description of these data are available .
This method is deprecated and will be removed in a future version. It is replaced by the DKDeviceConfigurationListener
. Read more .
The callback method tripFinished(post: PostGeneric, response: PostGenericResponse)
is replaced by tripFinished(result: TripResult)
which directly provides the useful information (see ).
The model is described in the References part.