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

*** ** * ** ***


```
public final class RoutingInfo.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo` | `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo.Builder#build()()` Constructs the `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo` defined by this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo.Builder#setCurrentStep(androidx.car.app.navigation.model.Step,androidx.car.app.model.Distance)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Step currentStep, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Distance currentDistance )` Sets the current `https://developer.android.com/reference/androidx/car/app/navigation/model/Step` and `https://developer.android.com/reference/androidx/car/app/model/Distance` to display in the template. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo.Builder#setJunctionImage(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 junctionImage)` Sets an image of a junction for the maneuver. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo.Builder#setLoading(boolean)(boolean isLoading)` Sets whether the `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo` is in a loading state. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo.Builder#setNextStep(androidx.car.app.navigation.model.Step)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Step nextStep)` Sets the next `https://developer.android.com/reference/androidx/car/app/navigation/model/Step`. |

## 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/RoutingInfo.Builder` instance.

## Public methods

### build

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

```
public @NonNull RoutingInfo build()
```

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

#### Requirements

The `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo` can be in a loading state by passing `true` to `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo.Builder#setLoading(boolean)`, in which case no other fields may be set. Otherwise, the current step and distance must be set. If the lane information is set with `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#addLane(androidx.car.app.navigation.model.Lane)`, then the lane image must also be set with `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#setLanesImage(androidx.car.app.model.CarIcon)`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutingInfo` does not meet the template's requirements |

### setCurrentStep

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

```
public @NonNull RoutingInfo.Builder setCurrentStep(
    @NonNull Step currentStep,
    @NonNull Distance currentDistance
)
```

Sets the current `https://developer.android.com/reference/androidx/car/app/navigation/model/Step` and `https://developer.android.com/reference/androidx/car/app/model/Distance` to display in the template.

A `https://developer.android.com/reference/androidx/car/app/navigation/model/Step` with a `https://developer.android.com/reference/androidx/car/app/navigation/model/Maneuver` of type `https://developer.android.com/reference/androidx/car/app/navigation/model/Maneuver#TYPE_UNKNOWN()` will shown here with the given icon.

#### Image Sizing Guidance

Images in the cue of the `https://developer.android.com/reference/androidx/car/app/navigation/model/Step` object, set with `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#setCue(java.lang.CharSequence)`, can contain image spans. To minimize scaling artifacts across a wide range of car screens, apps should provide images targeting a 216 x 72 dp bounding box. If necessary, those images in the spans will be scaled down to fit the bounding box while preserving their aspect ratios.

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 `currentStep` is `null` |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `currentDistance` is `null` |

### setJunctionImage

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

```
public @NonNull RoutingInfo.Builder setJunctionImage(@NonNull CarIcon junctionImage)
```

Sets an image of a junction for the maneuver.

For example, a photo-realistic view of the upcoming junction that the driver can see when executing the maneuver.

#### Image Sizing Guidance

To minimize scaling artifacts across a wide range of car screens, apps should provide images targeting a 500 x 312 dp bounding box. If the image exceeds this maximum size in either one of the dimensions, it will be scaled down to be centered inside the bounding box while preserving its aspect ratio. The aspect ratio should be greater than or equal to 1.6 in order to fit the horizontal space fully.

On smaller screens the junction image may result in the hiding of the `https://developer.android.com/reference/androidx/car/app/navigation/model/Lane` s, `https://developer.android.com/reference/androidx/car/app/navigation/model/TravelEstimate` or next `https://developer.android.com/reference/androidx/car/app/navigation/model/Step`.

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 `junctionImage` is `null` |

### setLoading

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

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

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

If set to `true`, the UI will show a loading indicator, and adding any other routing info will throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html`. The caller is expected to call `https://developer.android.com/reference/androidx/car/app/Screen#invalidate()` and send the new template content to the host once the data is ready. If set to `false`, the UI shows the actual routing info.

### setNextStep

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

```
public @NonNull RoutingInfo.Builder setNextStep(@NonNull Step nextStep)
```

Sets the next `https://developer.android.com/reference/androidx/car/app/navigation/model/Step`.

Unless set with this method, the next step won't be displayed.

#### Image Sizing Guidance

Images in the cue of the `https://developer.android.com/reference/androidx/car/app/navigation/model/Step` object, set with `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#setCue(java.lang.CharSequence)`, can contain image spans. To minimize scaling artifacts across a wide range of car screens, apps should provide images targeting a 216 x 72 dp bounding box. If necessary, those images in the spans will be scaled down to fit the bounding box while preserving their aspect ratios.

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 `nextStep` is `null` |