# Automatic Detections with Forced Trips

{% hint style="danger" %}
This document refers to deprecated parts of the platform and has been left intact to help customers with legacy integrations. In order to access the latest platform features and documentation, please go to <https://docs.sentiance.com>.
{% endhint %}

While in [automatic detection mode](https://legacy-docs.sentiance.com/sdk/appendix/controlled-detections/automatic-detections), the SDK can be forced to start a trip. Doing so will prevent the SDK from detecting stationary moments and force it to continue collecting trip data until the trip is explicitly stopped.

Once the forced trip is stopped, the SDK will resume automatic detections.

## Starting a Trip

You can start a trip as follows:

{% tabs %}
{% tab title="iOS" %}

```objectivec
[[SENTSDK sharedInstance] startTrip:metadata 
                          transportModeHint:SENTTransportModeUnknown
    success:^{
    }
    failure:^(SENTSDKStatus *status) {
}];
```

The `metadata` is an `NSDictionary` representing a map of string to string types. You can use it to attach any piece of information to this trip. The `transportModeHint` is a hint you can give the SDK about the type of transport the trip is (e.g. car, bicycle, etc.).

In case starting a trip fails, you can check the `SENTSDKStatus` object to determine the reason.
{% endtab %}

{% tab title="Android" %}

```java
startTrip(metadata, transportModeHint, new StartTripCallback() {
    @Override
    public void onSuccess () {
        // The trip was successfully started.
    }
    @Override
    public void onFailure (@Nullable SdkStatus sdkstatus) {
        // Something prevented the trip to start.
        // Check the status object for more details.
    }
});
```

The `metadata` is a map of string to string types. You can use it to attach any piece of information to this trip. The `transportModeHint` is a hint of type [`TransportMode`](https://legacy-docs.sentiance.com/sdk/api-reference/android/trip/transportmode) you can give the SDK about the type of transport the trip is (e.g. car, bicycle, etc.).

By passing a [`StartTripCallback`](https://legacy-docs.sentiance.com/sdk/api-reference/android/trip/starttripcallback) to the method, you will be notified when a trip is successfully started. If it fails, you can check the [`SdkStatus`](https://legacy-docs.sentiance.com/sdk/api-reference/android/sdkstatus) object to determine the reason.
{% endtab %}
{% endtabs %}

## Stopping a Trip

To stop a trip that you've started, call `stopTrip` as follows:

{% tabs %}
{% tab title="iOS" %}

```objectivec
[[SENTSDK sharedInstance] stopTrip:^{
    // successfully stopped the trip
  } failure:^(SENTSDKStatus *status) {
    // stopping the trip failed
}];
```

If stopping the trip fails, you can check the `SENTSDKStatus` to determine why. Note that if no trip was ongoing, `failure` will be called as well.

To check if a trip is ongoing before calling `stopTrip`, see [this](https://legacy-docs.sentiance.com/sdk/appendix/controlled-detections/checking-trip-status) guide.
{% endtab %}

{% tab title="Android" %}

```java
stopTrip(new StopTripCallback() {
    @Override
    public void onSuccess () {
    }
    @Override
    public void onFailure (@Nullable SdkStatus sdkstatus) {
    }
});
```

You can pass a [`StopTripCallback`](https://legacy-docs.sentiance.com/sdk/api-reference/android/trip/stoptripcallback) to this method to be notified when the trip is stopped. If stopping the trip fails, you can check the [`SdkStatus`](https://legacy-docs.sentiance.com/sdk/api-reference/android/sdkstatus) to determine why. Note that if no trip was ongoing, the [`onFailure()`](https://legacy-docs.sentiance.com/api-reference/android/trip/stoptripcallback#onfailure) method will be called as well.

To check if a trip is ongoing before calling [`stopTrip()`](https://legacy-docs.sentiance.com/api-reference/android/sentiance#starttrip), see [this](https://legacy-docs.sentiance.com/sdk/appendix/controlled-detections/checking-trip-status) guide.
{% endtab %}
{% endtabs %}
