Trip SDK Methods

Create Trip

Use the below code to create a trip directly from the SDK. Set Boolean value true to create offline trip and false to create online trip.
Kotlin
Java
1
Roam.createTrip(null, null, Boolean, object : RoamCreateTripCallback {
2
override fun onSuccess(roamTrip: RoamCreateTrip) {
3
// do something when create trip success
4
// access roam trip created timestamp with roamTrip.getCreatedAt
5
// access roam trip user id with roamTrip.getUserId
6
// access roam trip id with roamTrip.getTripId
7
}
8
9
override fun onFailure(roamError: RoamError) {
10
// do something when get trip details error
11
// access roam error code with roamError.getCode()
12
// access roam error message with roamError.getMessage()
13
}
14
})
Copied!
1
Roam.createTrip(null, null, Boolean, new RoamCreateTripCallback() {
2
@Override
3
public void onSuccess(RoamCreateTrip roamTrip) {
4
// do something when create trip success
5
// access roam trip created timestamp with roamTrip.getCreatedAt
6
// access roam trip user id with roamTrip.getUserId
7
// access roam trip id with roamTrip.getTripId
8
}
9
10
@Override
11
public void onFailure(RoamError roamError) {
12
// do something when get trip details error
13
// access roam error code with roamError.getCode()
14
// access roam error message with roamError.getMessage()
15
}
16
});
Copied!

Get Trip Details

Kotlin
Java
1
Roam.getTripDetails("ROAM-TRIP-ID", object : RoamTripDetailCallback {
2
override fun onSuccess(roamTrip: RoamTripDetail) {
3
// do something when get trip details success
4
// access roam trip created timestamp with roamTrip.getCreatedAt()
5
// access roam trip user id with roamTrip.getUserId()
6
// access roam trip id with roamTrip.getTripId()
7
}
8
9
override fun onFailure(roamError: RoamError) {
10
// do something when get trip details error
11
// access roam error code with roamError.getCode()
12
// access roam error message with roamError.getMessage()
13
}
14
})
Copied!
1
Roam.getTripDetails("ROAM-TRIP-ID", new RoamTripDetailCallback() {
2
@Override
3
public void onSuccess(RoamTripDetail roamTrip) {
4
// do something when get trip details success
5
// access roam trip created timestamp with roamTrip.getCreatedAt()
6
// access roam trip user id with roamTrip.getUserId()
7
// access roam trip id with roamTrip.getTripId()
8
}
9
10
@Override
11
public void onFailure(RoamError roamError) {
12
// do something when get trip details error
13
// access roam error code with roamError.getCode()
14
// access roam error message with roamError.getMessage()
15
}
16
});
Copied!

Start and Stop Trip

Start Trip

Use the below code to start the trip with the previously created trip id.
Kotlin
Java
1
Roam.startTrip("ROAM-TRIP-ID", "ROAM-TRIP-DESCRIPTION", object : RoamTripCallback {
2
override fun onSuccess(message: String) {
3
}
4
5
override fun onFailure(roamError: RoamError) {
6
// do something when get trip details error
7
// access roam error code with roamError.getCode()
8
// access roam error message with roamError.getMessage()
9
}
10
})
Copied!
1
Roam.startTrip("ROAM-TRIP-ID", "ROAM-TRIP-DESCRIPTION", new RoamTripCallback() {
2
@Override
3
public void onSuccess(String message) {
4
}
5
6
@Override
7
public void onFailure(RoamError roamError) {
8
// do something when get trip details error
9
// access roam error code with roamError.getCode()
10
// access roam error message with roamError.getMessage()
11
}
12
});
Copied!

Stop Trip

Kotlin
Java
1
Roam.stopTrip("ROAM-TRIP-ID", object : RoamTripCallback {
2
override fun onSuccess(message: String) {
3
4
}
5
6
override fun onFailure(roamError: RoamError) {
7
// do something when get trip details error
8
// access roam error code with roamError.getCode()
9
// access roam error message with roamError.getMessage()
10
}
11
})
Copied!
1
Roam.stopTrip("ROAM-TRIP-ID", new RoamTripCallback() {
2
@Override
3
public void onSuccess(String message) {
4
}
5
6
@Override
7
public void onFailure(RoamError roamError) {
8
// do something when get trip details error
9
// access roam error code with roamError.getCode()
10
// access roam error message with roamError.getMessage()
11
}
12
});
Copied!

Pause and Resume Trip

Pause Trip

Use the below code to pause the trip with the previously started trip id.
Kotlin
Java
1
Roam.pauseTrip("ROAM-TRIP-ID", object : RoamTripCallback {
2
override fun onSuccess(message: String) {
3
4
}
5
6
override fun onFailure(roamError: RoamError) {
7
// do something when get trip details error
8
// access roam error code with roamError.getCode()
9
// access roam error message with roamError.getMessage()
10
}
11
})
Copied!
1
Roam.pauseTrip("ROAM-TRIP-ID", new RoamTripCallback() {
2
@Override
3
public void onSuccess(String message) {
4
}
5
6
@Override
7
public void onFailure(RoamError roamError) {
8
// do something when get trip details error
9
// access roam error code with roamError.getCode()
10
// access roam error message with roamError.getMessage()
11
}
12
});
Copied!

Resume Trip

To resume the trip.
Kotlin
Java
1
Roam.resumeTrip("ROAM-TRIP-ID", object : RoamTripCallback {
2
override fun onSuccess(message: String) {
3
4
}
5
6
override fun onFailure(roamError: RoamError) {
7
// do something when get trip details error
8
// access roam error code with roamError.getCode()
9
// access roam error message with roamError.getMessage()
10
}
11
})
Copied!
1
Roam.resumeTrip("ROAM-TRIP-ID", new RoamTripCallback() {
2
@Override
3
public void onSuccess(String message) {
4
}
5
6
@Override
7
public void onFailure(RoamError roamError) {
8
// do something when get trip details error
9
// access roam error code with roamError.getCode()
10
// access roam error message with roamError.getMessage()
11
}
12
});
Copied!

Subscribe Trip Status

Subscribe to tripStatus using tripId to get real-time trip status.
Kotlin
Java
1
//subscribe to trip status
2
Roam.subscribeTripStatus("ROAM-TRIP-ID")
Copied!
1
//subscribe to trip status
2
Roam.subscribeTripStatus("ROAM-TRIP-ID");
Copied!
To stop receiving trip status updates, use the below method.
Kotlin
Java
1
//unsubscribe to trip status
2
Roam.unSubscribeTripStatus("ROAM-TRIP-ID")
Copied!
1
//unsubscribe to trip status
2
Roam.unSubscribeTripStatus("ROAM-TRIP-ID");
Copied!

Get Trip Status

Kotlin
Java
1
Roam.getTripStatus("ROAM-TRIP-ID", object : RoamTripStatusCallback {
2
override fun onSuccess(roamTrip: RoamTripStatus) {
3
// do something when get trip details success
4
// access roam trip distance with roamTrip.getDistance()
5
// access roam trip speed with roamTrip.getSpeed()
6
}
7
8
override fun onFailure(roamError: RoamError) {
9
// do something when get trip details error
10
// access roam error code with roamError.getCode()
11
// access roam error message with roamError.getMessage()
12
}
13
})
Copied!
1
Roam.getTripStatus("ROAM-TRIP-ID", new RoamTripStatusCallback() {
2
@Override
3
public void onSuccess(RoamTripStatus roamTrip) {
4
// do something when get trip details success
5
// access roam trip distance with roamTrip.getDistance()
6
// access roam trip speed with roamTrip.getSpeed()
7
}
8
9
@Override
10
public void onFailure(RoamError roamError) {
11
// do something when get trip details error
12
// access roam error code with roamError.getCode()
13
// access roam error message with roamError.getMessage()
14
}
15
});
Copied!

Get Active Trips

To get the active trips. Set Boolean value true to get offline trips and false to get online trips.
Kotlin
1
Roam.activeTrips(Boolean, object : RoamActiveTripsCallback {
2
override fun onSuccess(roamTrip: RoamTrip) {
3
roamTrip.activeTrips
4
}
5
6
override fun onFailure(roamError: RoamError) {
7
// do something when get trip details error
8
// access roam error code with roamError.getCode()
9
// access roam error message with roamError.getMessage()
10
}
11
})
Copied!

Get Trip Summary.

Kotlin
Java
1
Roam.getTripSummary("ROAM-TRIP-ID", object : RoamTripSummaryCallback {
2
override fun onSuccess(roamTrip: RoamTripSummary) {
3
// do something when get trip details success
4
// access roam trip distance covered with roamTrip.getDistanceCovered
5
// access roam trip route with roamTrip.getRoute
6
// access roam trip duration with roamTrip.getDuration
7
// access roam trip id with roamTrip.getTripId
8
}
9
10
override fun onFailure(roamError: RoamError) {
11
// do something when get trip details error
12
// access roam error code with roamError.getCode()
13
// access roam error message with roamError.getMessage()
14
}
15
})
Copied!
1
Roam.getTripSummary("ROAM-TRIP-ID", new RoamTripSummaryCallback() {
2
@Override
3
public void onSuccess(RoamTripSummary roamTrip) {
4
// do something when get trip details success
5
// access roam trip distance covered with roamTrip.getDistanceCovered
6
// access roam trip route with roamTrip.getRoute
7
// access roam trip duration with roamTrip.getDuration
8
// access roam trip id with roamTrip.getTripId
9
}
10
11
@Override
12
public void onFailure(RoamError roamError) {
13
// do something when get trip details error
14
// access roam error code with roamError.getCode()
15
// access roam error message with roamError.getMessage()
16
}
17
});
Copied!
Last modified 5mo ago