# TravelEstimate.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/TravelEstimate.java+class:androidx.car.app.navigation.model.TravelEstimate.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

*** ** * ** ***


```
public final class TravelEstimate.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder#Builder(androidx.car.app.model.Distance,androidx.car.app.model.DateTimeWithZone)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Distance remainingDistance, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/DateTimeWithZone arrivalTimeAtDestination )` Constructs a new builder of `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate`. |
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder#Builder(androidx.car.app.model.Distance,java.time.ZonedDateTime)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Distance remainingDistance, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/time/ZonedDateTime.html arrivalTimeAtDestination )` Constructs a new builder of `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate`. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate` | `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder#build()()` Constructs the `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate` defined by this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder#setRemainingDistanceColor(androidx.car.app.model.CarColor)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarColor remainingDistanceColor)` Sets the color of the remaining distance text. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder#setRemainingTime(java.time.Duration)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/time/Duration.html remainingTime)` Sets the estimated time remaining until arriving at the destination. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder#setRemainingTimeColor(androidx.car.app.model.CarColor)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarColor remainingTimeColor)` Sets the color of the remaining time text. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder#setRemainingTimeSeconds(long)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = "-1") long remainingTimeSeconds)` Sets the estimated time remaining until arriving at the destination, in seconds. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 5) https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder#setTripIcon(androidx.car.app.model.CarIcon)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarIcon tripIcon)` Sets a `https://developer.android.com/reference/androidx/car/app/model/CarIcon` that is associated with the current `https://developer.android.com/reference/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/TravelEstimate.Builder` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 5) https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate.Builder#setTripText(androidx.car.app.model.CarText)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarText tripText)` Sets the trip text. |

## Public constructors

### Builder

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

```
public Builder(
    @NonNull Distance remainingDistance,
    @NonNull DateTimeWithZone arrivalTimeAtDestination
)
```

Constructs a new builder of `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Distance remainingDistance` | The estimated remaining `https://developer.android.com/reference/androidx/car/app/model/Distance` until arriving at the destination |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/DateTimeWithZone arrivalTimeAtDestination` | The arrival time with the time zone information provided for the destination |

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

### Builder

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

```
@RequiresApi(value = 26)
public Builder(
    @NonNull Distance remainingDistance,
    @NonNull ZonedDateTime arrivalTimeAtDestination
)
```

Constructs a new builder of `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Distance remainingDistance` | The estimated remaining `https://developer.android.com/reference/androidx/car/app/model/Distance` until arriving at the destination |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/time/ZonedDateTime.html arrivalTimeAtDestination` | The arrival time with the time zone information provided for the destination |

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

## Public methods

### build

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

```
public @NonNull TravelEstimate build()
```

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

### setRemainingDistanceColor

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

```
public @NonNull TravelEstimate.Builder setRemainingDistanceColor(@NonNull CarColor remainingDistanceColor)
```

Sets the color of the remaining distance text.

Depending on contrast requirements, capabilities of the vehicle screens, or other factors, the color may be ignored by the host or overridden by the vehicle system.

If not set, `https://developer.android.com/reference/androidx/car/app/model/CarColor#DEFAULT()` will be used.

Custom colors created with `https://developer.android.com/reference/androidx/car/app/model/CarColor#createCustom(int,int)` are not supported.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `remainingDistanceColor` is not supported |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `remainingDistanceColor` is `null` |

### setRemainingTime

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

```
@RequiresApi(value = 26)
public @NonNull TravelEstimate.Builder setRemainingTime(@NonNull Duration remainingTime)
```

Sets the estimated time remaining until arriving at the destination.

If not set, `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate#REMAINING_TIME_UNKNOWN()` will be used.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `remainingTime` is a negative duration but not `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate#REMAINING_TIME_UNKNOWN()` |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `remainingTime` is `null` |

### setRemainingTimeColor

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

```
public @NonNull TravelEstimate.Builder setRemainingTimeColor(@NonNull CarColor remainingTimeColor)
```

Sets the color of the remaining time text.

Depending on contrast requirements, capabilities of the vehicle screens, or other factors, the color may be ignored by the host or overridden by the vehicle system.

If not set, `https://developer.android.com/reference/androidx/car/app/model/CarColor#DEFAULT()` will be used.

Custom colors created with `https://developer.android.com/reference/androidx/car/app/model/CarColor#createCustom(int,int)` are not supported.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `remainingTimeColor` is not supported |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `remainingTimecolor` is `null` |

### setRemainingTimeSeconds

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

```
public @NonNull TravelEstimate.Builder setRemainingTimeSeconds(@IntRange(from = "-1") long remainingTimeSeconds)
```

Sets the estimated time remaining until arriving at the destination, in seconds.

If not set, `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate#REMAINING_TIME_UNKNOWN()` will be used.

Note that `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate#REMAINING_TIME_UNKNOWN()` may not be supported depending on where the `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate` is used. See the documentation of where `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate` is used for any restrictions that might apply.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `remainingTimeSeconds` is a negative value but not `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate#REMAINING_TIME_UNKNOWN()` |

### setTripIcon

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

```
@RequiresCarApi(value = 5)
public @NonNull TravelEstimate.Builder setTripIcon(@NonNull CarIcon tripIcon)
```

Sets a `https://developer.android.com/reference/androidx/car/app/model/CarIcon` that is associated with the current `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate`

See `https://developer.android.com/reference/androidx/car/app/model/CarIcon` for more details related to providing icon and image resources that work with different car screen pixel densities.

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

### setTripText

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

```
@RequiresCarApi(value = 5)
public @NonNull TravelEstimate.Builder setTripText(@NonNull CarText tripText)
```

Sets the trip text.

A text that provides additional information about this `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate`, such as drop off/pick up information, and battery level, that should be displayed on the screen alongside the remaining distance and time.

For example "Pick up Alice", "Drop off Susan", or "Battery Level is Low".

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `tripText` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `tripText` contains unsupported spans |

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