# Trip recording widget

## Principle

The widget is a button that lets the user control the trip recording. Possible actions are:

* Start a trip recording
* Check that the current trip is being recorded
* Stop a trip recording
* Cancel a trip recording.

## How to display the trip recording widget?

There are two ways to integrate the trip recording widget into your application:

The first one is embedding it in XML layout:

```xml
<fragment
    android:id="@+id/start_stop_trip_button"
    android:name="com.drivequant.drivekit.tripanalysis.triprecordingwidget.recordingbutton.DKTripRecordingButton"
    android:layout_width="match_parent"
    android:layout_height="60dp" />
```

The second way is getting it from `DriveKitTripAnalysisUI`:

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

```kotlin
fun newTripRecordingButtonFragment(): DKTripRecordingButton
```

{% endtab %}
{% endtabs %}

If you need to programmatically display the stop trip confirmation dialog (for example, when the user taps a start trip notification), you can call the public method `showConfirmationDialog()` of the `DKTripRecordingButton` instance.&#x20;

{% hint style="warning" %}
**Warning**: This dialog won’t appear if the `DKTripRecordingUserMode` doesn’t allow the user to end a trip.
{% endhint %}

## Trip recording widget configurations

The button has 4 configurations to cover all possible scenarios, and its display can be adjusted using the tripRecordingUserMode parameter.

1. `NONE`: The button is hidden and the trip recording is fully automatic. This is the simplest mode, and the one we prefer.<br>
2. `START_STOP`: The button is displayed and the user has total control over the trip recording cycle: start, stop and cancel. In this configuration, autostart remains active.<br>
3. `START_ONLY`: The user can start a trip manually but cannot stop or cancel it under any circumstances. Recording stops automatically. In this configuration, autostart remains active.<br>
4. `STOP_ONLY`: The user cannot start a trip manually. The start of a trip is detected automatically. The user can only stop the trip to get his results or cancel the recording&#x20;

The default value is `START_STOP`.

To set the button mode, call the following method:

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

```kotlin
var tripRecordingUserMode: DKTripRecordingUserMode
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.drivequant.com/trip-analysis/user-interface/android/trip-recording-widget.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
