Start Quick Trip (Android)

Explore how to start a quick trip on Android with Trips v2.

A Quick Trip creates and starts a trip immediately with a single method. Creating a quick trip is similar to creating a trip.

ParameterTypeDescriptionOptional

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

Name of the trip

tripDescription

String

Trip description

isLocal

boolean

Value determining if the trip is a local trip.

Along with the above trip object, you need to pass an additional parameter for trackingMode which is optional and defaults to active tracking mode.

Roam.startTrip(trip, RoamTrackingMode.active, new RoamTripCallback() {
                    @Override
                    public void onSuccess(RoamTripResponse response) {
                       //get trip details
                    }

                    @Override
                    public void onError(Error error) {
                       //get error details
                    }
                });

To start a quick trip in custom tracking mode, refer to the following code snippet block.

RoamTrackingMode roamTrackingMode = new RoamTrackingMode.Builder(distanceFilter, stopDuration)
                        .setDesiredAccuracy(RoamTrackingMode.DesiredAccuracy.HIGH)
                        .build();

Roam.startTrip(trip, roamTrackingMode, new RoamTripCallback() {
                    @Override
                    public void onSuccess(RoamTripResponse response) {
                       //get trip details
                    }

                    @Override
                    public void onError(Error error) {
                       //get error details
                    }
                });

The list of responses and error parameters are given below with their descriptions.

To access the status parameters:

ParameterTypeDescription

response.getCode()

Integer

The response code of the method.

response.getMessage()

String

The response message of the method.

To access trip responses:

ParameterTypeDescription

getTripDetails().getTripId()

String

Unique identifier for the object.

getTripDetails().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.

getTripDetails().getTripName()

String

The trip name

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

The 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

To access user details:

ParameterTypeDescription

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

To access error details:

ParameterTypeDescription

error.getErrorCode()

Integer

The error response code of the method.

error.getErrorMessage()

String

Error response message of the method.

error.getErrorDescription()

String

Error response description of the method.

error.getErrors().get(i).getMessage()

String

Message for error detail.

error.getErrors.get(i).getField()

String

The field for error detail.

Last updated