# Trip Manager Status

The application can register a listener to be informed of important lifecycle events such as trip detection enabled, recording started, and/or failures. This can be done by adding a listener while the app is running.

```kotlin
// Listen for trip manager status updates
ImsTripManager.addTripStatusListener(object : ImsTripManager.TripStatusListener {
    override fun onTripStatusUpdate(tripStatus: ImsTripStatus) {
        tripStatusData.value = tripStatus    // Sample app uses LiveData
        when (tripStatus.tripState) {
            ImsTripStatus.TripState.ENABLED -> {}
            ImsTripStatus.TripState.STARTED -> Log.d(LOG_TAG, "Trip Started.")
            ImsTripStatus.TripState.CHECKING -> Log.d(LOG_TAG, "Checking for a Trip .")
            ImsTripStatus.TripState.STOPPED -> Log.d(LOG_TAG, "Trip Ended.")
            ImsTripStatus.TripState.DISABLED -> {}
        }
    }
})
```

You can also query the current trip manager state at any time.

```kotlin
ImsTripManager.tripManagerStatus
```


---

# 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://sdk.ims.tech/readme/android/using-the-sdk/trip-detection-and-recording/trip-manager-status.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.
