This section shows how to get the vehicle ready for trips. You must complete
each of the following steps before your backend can match a vehicle to a trip.

## Set up listener

Since the Driver SDK performs actions in the
background, use the `DriverStatusListener` to trigger notifications when certain
events occur, such as errors, warnings, or debug messages. Errors can be
transient in nature (such as `BACKEND_CONNECTIVITY_ERROR`), or they might
cause location updates to stop permanently. For example, if you receive a
`VEHICLE_NOT_FOUND` error, it indicates a configuration error.

The following example shows a `DriverStatusListener` implementation:

```java
class MyStatusListener implements DriverStatusListener {
  /** Called when background status is updated, during actions such as location reporting. */
  @Override
  public void updateStatus(
      StatusLevel statusLevel, StatusCode statusCode, String statusMsg, @Nullable Throwable cause) {
    // Existing implementation

    if (cause != null && cause instanceof StatusRuntimeException) {
      if (Status.NOT_FOUND.getCode().equals(cause.getStatus().getCode())) {
        // NOT_FOUND gRPC exception thrown by Fleet Engine.
      }
    }
  }
}

DriverContextBuilder.setDriverStatusListener(new MyStatusListener());
```

## Enable location updates

After you set up the listener, enable location updates as follows:

### Java

```java
RidesharingVehicleReporter reporter = ...;

reporter.enableLocationTracking();
```

### Kotlin

```kotlin
val reporter = ...

reporter.enableLocationTracking()
```

> [!NOTE]
> **Note:** Calling `reporter.enableLocationTracking()` does not automatically set the vehicle state to `ONLINE`. You must set the vehicle state explicitly. For details, see [Set the vehicle state to online](https://developers.google.com/maps/documentation/mobility/driver-sdk/on-demand/android/vehicle-ready.md.txt#state).

### Set the update interval

By default, the Driver SDK sends location updates at 10-second intervals
interval when the vehicle state is `ONLINE`. You can change this interval with
`reporter.setLocationReportingInterval(long, TimeUnit)`. The minimum supported
update interval is 5 seconds. More frequent updates may result in slower
requests and errors.

## Set the vehicle state to online

When you turn on location updates, you can set the vehicle state to `ONLINE` to
make the vehicle available for `SearchVehicles` queries in Fleet Engine. The
Driver SDK sends the updated vehicle state along with the location updates.

You can set the vehicle state directly in the Driver SDK or in the Fleet Engine
server. For more information, see [Update a Vehicle](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/vehicles/on-demand-vehicle-fields.md.txt#vehicle_state_field).

The following examples show how to set the vehicle state to online in the Driver
SDK:

### Java

```java
RidesharingVehicleReporter reporter = ...;

reporter.enableLocationTracking();
reporter.setVehicleState(VehicleState.ONLINE);
```

### Kotlin

```kotlin
val reporter = ...

reporter.enableLocationTracking()
reporter.setVehicleState(VehicleState.ONLINE)
```

> [!CAUTION]
> **Caution:** You need to have location updates turned on before you set the vehicle online. If you try to do this with location updates off, you'll get an `IllegalStateException` error message.

The `StatusListener` also reports any errors that occur when updating the
vehicle state.

## What's next

[Set the trip details](https://developers.google.com/maps/documentation/mobility/driver-sdk/on-demand/android/trip-details.md.txt)