# Trip.Builder

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/navigation/model/Trip.java+class:androidx.car.app.navigation.model.Trip.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

*** ** * ** ***


```
public final class Trip.Builder
```

<br />

*** ** * ** ***

A builder of `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder#Builder()()` Constructs an empty `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder` instance. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder#addDestination(androidx.car.app.navigation.model.Destination,androidx.car.app.navigation.model.TravelEstimate)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Destination destination, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate destinationTravelEstimate )` Adds a destination to the trip. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder#addStep(androidx.car.app.navigation.model.Step,androidx.car.app.navigation.model.TravelEstimate)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Step step, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate stepTravelEstimate)` Adds a step to the trip. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Trip` | `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder#build()()` Constructs the `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip` defined by this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder#setCurrentRoad(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html currentRoad)` Sets a description of the current road. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder#setLoading(boolean)(boolean isLoading)` Sets whether the `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip` is in a loading state. |

## Public constructors

### Builder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public Builder()
```

Constructs an empty `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip.Builder` instance.

## Public methods

### addDestination

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public @NonNull Trip.Builder addDestination(
    @NonNull Destination destination,
    @NonNull TravelEstimate destinationTravelEstimate
)
```

Adds a destination to the trip.

Destinations must be added in order of arrival. A destination is not required. Display surfaces may or may not use the destination and if multiple destinations are added the display may only show information about the first destination.

For every destination added, a corresponding `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate` must be provided. Display surfaces may or may not use the destination travel estimate and if multiple destination travel estimates are added the display may only show information about the first destination travel estimate.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `step` or `stepTravelEstimate` are ` null` |

### addStep

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public @NonNull Trip.Builder addStep(@NonNull Step step, @NonNull TravelEstimate stepTravelEstimate)
```

Adds a step to the trip.

Steps must be added in order of arrival. A step is not required. Display surfaces may or may not use the step and if multiple steps are added the display may only show information about the first step.

For every step added, a corresponding `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate` must be provided. Display surfaces may or may not use the step travel estimate and if multiple step travel estimates are added the display may only show information about the first step travel estimate.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `step` or `stepTravelEstimate` are ` null` |

### build

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public @NonNull Trip build()
```

Constructs the `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip` defined by this builder.

### setCurrentRoad

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public @NonNull Trip.Builder setCurrentRoad(@NonNull CharSequence currentRoad)
```

Sets a description of the current road.

Spans are not supported in the input string and will be ignored.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `currentRoad` is `null` |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/CarText` |   |

### setLoading

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public @NonNull Trip.Builder setLoading(boolean isLoading)
```

Sets whether the `https://developer.android.com/reference/androidx/car/app/navigation/model/Trip` is in a loading state.

If set to `true`, the UI may show a loading indicator, and adding any steps or step travel estimates will throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html`.