Manage the Zendrive Trip Lifecycle

Zendrive's Trip Lifecycle comprises of the following:

Automatic Trip Lifecycle

Zendrive SDK automatically detects trips and provides a number of events to registered event listeners. Each listener will be provided with event data which can be used to implement your business logic.

The Automatic Trip Lifecycle comprises the following:

  1. The user starts driving. The user may be driving themselves or be a passenger.

  2. Zendrive SDK detects that a trip has started and the registered event listener is called with the on-drive-start event type.

  3. If the OS kills the application or if the device restarts, Zendrive SDK resumes the trip and the registered event listener is called with the on-drive-resume event.

  4. If there's a collision, the registered event listener is called with the on-accident event. You must apply your own business logic using the returned data.

  5. The user stops driving and Zendrive SDK detects trip end. The registered event listener is called with an event of kind on-drive-end.

  6. After the trip end event is notified, Zendrive SDK takes time to process the trip. After processing, the registered event listener is called with an event of kind on-drive-analyzed.

In each of these cases you may implement your own business logic with data.

In case of extended delays, that is, delay beyond 5 minutes, Zendrive SDK may not notify the on-drive-resume event. Instead, it notifies the on-drive-end event.

Manual Trip Lifecycle

In a manual trip, your application uses the startDrive and stopManualDrive methods to initiate and end trip detection. See Manual Trip Tagging for more information.

Zendrive SDK provides a number of events to the registered event listeners during a trip lifecycle. Each listener will be provided with event data which can be used to implement your business logic.

The Manual Trip Lifecycle comprises the following:

  1. Your application calls the startDrive method to start a trip. The registered event listener is called with an event of kind on-drive-start.

  2. If the OS kills the application or the device restarts, the SDK resumes the trip and the registered event listener is called with an event of kind on-drive-resume.

  3. If there is a collision, the registered event listener is called with an event of kind on-accident. In this case, you need to apply your own business logic using the returned data.

  4. Your application calls the stopManualDrive method to end the trip. The registered event listener is called with an event of kind on-drive-end.

  5. After the trip end event is notified, Zendrive SDK takes time to process the trip. After processing, the registered event listener is called with an event of kind on-drive-analyzed.

In each of these cases you may implement your own business with given data.

In the case of a manual trip, Zendrive SDK will never notify on-drive-end method on its own, even on device restart. You will need to call the stopManualDrive to trigger a trip end.

Last updated

Was this helpful?