Trip v1 SDK Methods (Android)

Explore the Android SDK Methods for Trip API v1. Check out the latest methods if you are using Trips API v2!

Create Trip

Use the code below to create a trip directly from the SDK. Set Boolean value true to create offline trips and false to create online trips.

Roam.createTrip(null, null, Boolean, object : RoamCreateTripCallback {
      override fun onSuccess(roamTrip: RoamCreateTrip) {
            // do something when create trip success
            // access roam trip created timestamp with roamTrip.getCreatedAt
            // access roam trip user id with roamTrip.getUserId
            // access roam trip id with roamTrip.getTripId
      }

      override fun onFailure(roamError: RoamError) {
                // do something when get trip details error
                // access roam error code with roamError.getCode()
                // access roam error message with roamError.getMessage()
        }
})

Get Trip Details

Roam.getTripDetails("ROAM-TRIP-ID", object : RoamTripDetailCallback {
      override fun onSuccess(roamTrip: RoamTripDetail) {
              // do something when get trip details success
              // access roam trip created timestamp with roamTrip.getCreatedAt()
              // access roam trip user id with roamTrip.getUserId()
              // access roam trip id with roamTrip.getTripId()
      }

      override fun onFailure(roamError: RoamError) {
                // do something when get trip details error
                // access roam error code with roamError.getCode()
                // access roam error message with roamError.getMessage()
        }
})

Start and Stop Trip

Start Trip

Use the code below to start the trip with the previously created tripID.

 Roam.startTrip("ROAM-TRIP-ID", "ROAM-TRIP-DESCRIPTION", object : RoamTripCallback {
        override fun onSuccess(message: String) {
        }

        override fun onFailure(roamError: RoamError) {
                // do something when get trip details error
                // access roam error code with roamError.getCode()
                // access roam error message with roamError.getMessage()
        }
})

Stop Trip

Roam.stopTrip("ROAM-TRIP-ID", object : RoamTripCallback {
      override fun onSuccess(message: String) {

      }

      override fun onFailure(roamError: RoamError) {
                // do something when get trip details error
                // access roam error code with roamError.getCode()
                // access roam error message with roamError.getMessage()
        }
})

Pause and Resume Trip

Pause Trip

Use the code below to pause the trip with the previously started trip id.

Roam.pauseTrip("ROAM-TRIP-ID", object : RoamTripCallback {
      override fun onSuccess(message: String) {

      }

      override fun onFailure(roamError: RoamError) {
                // do something when get trip details error
                // access roam error code with roamError.getCode()
                // access roam error message with roamError.getMessage()
        }
})

Resume Trip

To resume the trip,

Roam.resumeTrip("ROAM-TRIP-ID", object : RoamTripCallback {
      override fun onSuccess(message: String) {

      }

      override fun onFailure(roamError: RoamError) {
                // do something when get trip details error
                // access roam error code with roamError.getCode()
                // access roam error message with roamError.getMessage()
        }
})

Subscribe to Trip Status

Subscribe to tripStatus using the tripId to get real-time trip status.

//subscribe to trip status
Roam.subscribeTripStatus("ROAM-TRIP-ID")

To stop receiving trip status updates, use the method below.

//unsubscribe to trip status
Roam.unSubscribeTripStatus("ROAM-TRIP-ID")

Get Trip Status

Roam.getTripStatus("ROAM-TRIP-ID", object : RoamTripStatusCallback {
      override fun onSuccess(roamTrip: RoamTripStatus) {
                // do something when get trip details success
                // access roam trip distance with roamTrip.getDistance()
                // access roam trip speed with roamTrip.getSpeed()
      }

      override fun onFailure(roamError: RoamError) {
                // do something when get trip details error
                // access roam error code with roamError.getCode()
                // access roam error message with roamError.getMessage()
        }
})

Get Active Trips

To retrieve the active trips, set the Boolean value to true to get offline trips and to false to get online trips.

Roam.activeTrips(Boolean, object : RoamActiveTripsCallback {
        override fun onSuccess(roamTrip: RoamTrip) {
                roamTrip.activeTrips
        }

        override fun onFailure(roamError: RoamError) {
                // do something when get trip details error
                // access roam error code with roamError.getCode()
                // access roam error message with roamError.getMessage()
        }
})

Get Trip Summary

Roam.getTripSummary("ROAM-TRIP-ID", object : RoamTripSummaryCallback {
        override fun onSuccess(roamTrip: RoamTripSummary) {
                // do something when get trip details success
                // access roam trip distance covered with roamTrip.getDistanceCovered
                // access roam trip route with roamTrip.getRoute
                // access roam trip duration with roamTrip.getDuration
                // access roam trip id with roamTrip.getTripId
        }

        override fun onFailure(roamError: RoamError) {
                // do something when get trip details error
                // access roam error code with roamError.getCode()
                // access roam error message with roamError.getMessage()
        }
})

Last updated