Trip Tracking is a powerful module designed for applications that need to track drivers' routes in real-time. By integrating the SDK into your application, you can record and manage the entire journey of a driver from start to finish.
Getting Started
Install the SDK
Before using the trip feature, you need to install the Android Tracking SDK into your project. Please refer to Getting Started for a step-by-step guide.
Configure an Asset
Next, we will create an asset and bind it to a GPS device so that we can track the asset as it moves through its Trip.
The trip feature in the Tracking SDK allows you to monitor and manage trips for your assets. This feature provides functionality for starting, updating, ending, and deleting trips, as well as retrieving trip summaries and details.
Starting a Trip
When a driver starts a trip, call the startTrip method. This will record the start time and the starting location of the trip.
1
val tripProfile = TripProfile(
2
name = "A Sample Trip",
3
description = "This is a sample trip",
4
attributes = mapOf("keyOfAttribute" to "value of attribute"),
5
metaData = mapOf("keyOfMetaData" to "value of meta data"),
6
stops = listOf(
7
TripStop(
8
name = "Trip stops",
9
metaData = mapOf("keyOfMetaData" to "value of trip stop meta data"),
override fun onFailure(exception: AssetException) {
7
// Handle error
8
}
9
})
Ending a Trip
When a trip ends, such as when the driver reaches the destination or completes the last delivery of his route, you can mark a trip as completed, by calling the endTrip method.
override fun onFailure(exception: AssetException) {
7
// Handle error
8
}
9
})
Retrieving Trip details
You can use the getTripInfo method to get detailed information about a trip. If the provided trip ID is null, details of the ongoing trip are returned. Otherwise, if a valid trip ID is provided, details of the given trip are returned.
override fun onFailure(exception: AssetException) {
8
// Handle the error
9
}
10
})
Deleting a Trip
You can delete a trip by providing the trip ID. However, note that once a trip is deleted, calling any other trip-related methods will no longer succeed.