Supplementary for Android

The following information enables you to create a mock trip for the mobile app.

Simulate trips

When you start a mock trip, a route will be generated from the startLocation to the test site. Location updates will be sent to the ARRIVE server at regular intervals. To cancel a mock trip, use cancelMockTrip.

Start a Mock Trip

Use the following code snippet to start a mock trip to your site. Replace the startLocation’s latitude and longitude with a location that is two or three miles from your site.

final LatLng startLocation = new LatLng(37.427507, -122.138655);
CSUserSession.getInstance().startMockTripToSiteWithIdentifier("SITE_ID", startLocation);

You can also subscribe to EventBus before calling this method to listen for successful or failed events for the method using the following code snippet:

    //create an observer for listening start mock trip event
    final Action1<Event> startMockTripToSiteEventObserver = new Action1<Event>() {
        @Override
        public void call(Event event) {
            if(event.status == Status.SUCCESS) {
                Log.d(TAG, String.format("Succesfully started mock trip to site"));
                //do something
            }
            else if (event.status == Status.FAILURE) {
                Log.d(TAG, String.format("Unsuccessful in starting mock trip to site due to: %s", (CSErroCode)event.object));
                //do something
            }
        }
    };

//subscribe to the event on the eventBus
CSUserSession.getInstance().getEventBus().getObservable(Path.USER, START_MOCK_TRIP).subscribe(startMockTripToSiteEventObserver);

Cancel a Mock Trip

Use the following code snippet to cancel a mock trip:

CSUserSession.getInstance().cancelMockTrip();

You can also subscribe to EventBus before calling this method to listen for successful or failed events for the method using the following code snippet:

    //create an observer for listening cancel mock trip event
    final Action1<Event> cancelMockTripToSiteEventObserver = new Action1<Event>() {
        @Override
        public void call(Event event) {
            if(event.status == Status.SUCCESS) {
                Log.d(TAG, String.format("Succesfully cancelled mock trip to site"));
                //do something
            }
            else if (event.status == Status.FAILURE) {
                Log.d(TAG, String.format("Unsuccessful in cancelling mock trip to site due to: %s", (CSErroCode)event.object));
                //do something
            }
        }
    };

//subscribe to the event on the eventBus
CSUserSession.getInstance().getEventBus().getObservable(Path.USER, CANCEL_MOCK_TRIP).subscribe(cancelMockTripToSiteEventObserver);