Create Trip (Android)
Explore how to create a trip on Android with Trips v2.
Last updated
Explore how to create a trip on Android with Trips v2.
Last updated
To create a trip, you need to create an object for the trip and assign it with the RoamTrip() builder class. Below are the parameters and their descriptions for the trip object.
Parameter | Type | Description | Optional |
---|---|---|---|
When you create a trip, you can add stop locations which are nothing but locations where the user taking the trip will receive events for entry and exit. To create and assign stops to a trip, create objects for a single or multiple stops and assign them with the RoamTripStops() class. Below are the parameters and their descriptions for the stop object.
Parameter | Type | Description | Optional |
---|---|---|---|
Below is an example code for creating a trip with two stops. Let's create our stop objects.
Now, let's create an object for the trip and update the parameters along with stop which was created above.
Now that the trip and stop objects are created, let's create the trip with Roam.createTrip() method.
The list of responses and error parameters are given below with their descriptions.
To access the status parameters:
To access the trip response:
To access user details:
To access stop details:
To access error details:
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
metadata
JSONObject
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
tripName
String
The name of the trip
tripDescription
String
The description for the trip
isLocal
boolean
Value determining if the trip is a local trip.
user
String
The user ID
Stops
List <RoamTripStops>
The list of stop object
metadata
JSONObject
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
stopName
String
The stop name
stopDescription
String
The stop description
geometryRadius
Double
The stop radius
geometry
List<Double>
The coordinates list with longitude and latitude.
address
String
The stop address
response.getCode()
Integer
The response code of the method.
response.getMessage()
String
The response message of the method.
getTripDetails().getTripId()
String
Unique identifier for the object.
getTripDetails().getMetadata()
Object
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
getTripDetails().getTripName()
String
The name of the trip
getTripDetails().getTripDescription()
String
The trip’s description
getTripDetails().getTripState()
String
The current state of the trip is either created, started, or ended.
getTripDetails().getIsLocal()
boolean
Value determining if the trip is a local trip.
getTripDetails().getTotalDistance()
double
The total distance covered by the user for this trip.
getTripDetails().getTotalDuration()
double
The total duration taken by the user for this trip.
getTripDetails().getTotalElevationGain()
double
The total elevation gain covered by the user for this trip.
getTripDetails().createdAt()
String
Timestamp of when the trip was created
getTripDetails().updatedAt()
String
Timestamp of when the trip was updated
getTripDetails().startedAt()
String
Timestamp of when the trip was started by the user
getTripDetails().endedAt()
String
Timestamp of when the trip was ended by the user
getUser().getId()
String
Unique identifier for the object.
getUser().getMetadata()
Object
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
getUser().getDescription()
String
User description
getUser().getName()
String
The user's full name
getStops().get(i).getStopName()
String
The stop name
getStops().get(i).getStopDescription()
String
The stop description
getStops().get(i).getMetadata()
Object
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
getStops().get(i).getGeometryRadius()
double
The stop radius.
getStops().get(i).getGeometry()
Object
The coordinates list with longitude and latitude.
getStops().get(i).getArrivedAt()
String
The timestamp when the user arrived at the stop.
getStops().get(i).getDepartedAt()
String
The timestamp when the user departed from the stop.
getStops().get(i).getAddress()
String
The stop address .
error.getErrorCode()
Integer
The error response code of the method.
error.getErrorMessage()
String
The error response message of the method.
error.getErrorDescription()
String
The error response description of the method.
error.getErrors().get(i).getMessage()
String
The message for error detail.
error.getErrors.get(i).getField()
String
The field for error detail.