Trip Lifecycle
The Zendrive architecture helps you get a bird's eye view on how the Zendrive platform works and all the features and functionalities it provides.
Below is the high-level system diagram of the Zendrive Android and iOS architecture for automatic and manual trips.
Automatic Trip Lifecycle
The Zendrive SDK automatically detects trips and provides a number of listeners for callbacks during different events in the trip. Each callback returns data which can be used to implement your business logic. The following table provides the methods called for each step in the trip lifecycle, for both Android and iOS.

1. The vehicle begins moving. The user may be a driver or a passenger.
2. The SDK detects a trip.
onDriveStart()
processStartOfDrive:
3. If the OS kills the application or the device restarts, the SDK resumes the trip. (See warning A)
onDriveResume()
processResumeOfDrive:
4. If there is a collision, the SDK generates a callback. (See warning B)
onAccident()
processAccidentDetected:
5. The user stops driving.
6. The SDK detects that the trip ends.
onDriveEnd()
processEndOfDrive:
7. The SDK processes the trip. After processing, it generates an analysis callback.
onDriveAnalyzed()
processAnalysisOfDrive:
Each handler can be used to implement your own business logic.
Warning A: In case of extended delays i.e. any delay beyond 5 minutes, the SDK may not resume the trip and call the onDriveResume()
method. Instead, it sends an onDriveEnd()
call.
Warning B: The onAccident()
and processAccidentDetected:
are just callbacks. You must implement your own business logic using the data returned.
Manual Trip Lifecycle
In a manual trip, your app uses the startDrive()
and stopManualDrive()
methods to initiate and end trip detection. The Zendrive SDK provides a number of listeners for callbacks during different events in the trip. Each callback returns data which can be used to implement your business logic. The following table provides the methods called for each step in the manual trip lifecycle, for both Android and iOS.

1a. Your application calls a method to start a trip.
StartDrive()
StartManualDrive:
1b. The SDK calls a method in response.
onDriveStart()
processStartOfDrive:
2. If the OS kills the application or the device restarts, the SDK resumes the trip. (See warning C)
onDriveResume()
processResumeOfDrive:
3. If there is a collision, the SDK generates a callback. (See warning D)
onAccident()
processAccidentDetected:
4a. Your application calls a method to end the trip.
stopManualDrive()
stopManualDrive:
4b. The SDK calls a method in response.
onDriveEnd()
processEndOfDrive:
5. The SDK processes the trip. After processing, it generates an analysis callback.
onDriveAnalyzed()
processAnalysisOfDrive:
Each handler can be used to implement your own business logic.
Warning C: In the case of a manual trip, the SDK will never call the onDriveEnd()
method on its own, even on device restart. You must call stopManualDrive()
to trigger a trip end.
Warning D: The onAccident()
and processAccidentDetected:
are just callbacks. You must implement your own business logic using the data returned.
Was this helpful?