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

*** ** * ** ***


```
public final class Step.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#Builder()()` Constructs a new builder of `https://developer.android.com/reference/androidx/car/app/navigation/model/Step`. |
| `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#Builder(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 cue)` Constructs a new builder of `https://developer.android.com/reference/androidx/car/app/navigation/model/Step` with a cue, with support for multiple length variants. |
| `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#Builder(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html cue)` Constructs a new builder of `https://developer.android.com/reference/androidx/car/app/navigation/model/Step` with a cue. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#addLane(androidx.car.app.navigation.model.Lane)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Lane lane)` Adds the information of a single road lane at the point where the driver should execute this step. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Step` | `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#build()()` Constructs the `https://developer.android.com/reference/androidx/car/app/navigation/model/Step` defined by this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#setCue(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html cue)` Sets a text description of this maneuver. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#setLanesImage(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 lanesImage)` Sets an image representing all the lanes. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#setManeuver(androidx.car.app.navigation.model.Maneuver)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Maneuver maneuver)` Sets the maneuver to be performed on this step. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#setRoad(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html road)` Sets a text description of the road for the step. |

## Public constructors

### Builder

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

```
public Builder()
```

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

### Builder

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

```
public Builder(@NonNull CarText cue)
```

Constructs a new builder of `https://developer.android.com/reference/androidx/car/app/navigation/model/Step` with a cue, with support for multiple length variants.

See `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#setCue(java.lang.CharSequence)` for details on span support in the input string.

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

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#Builder(java.lang.CharSequence)` |   |

### Builder

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

```
public Builder(@NonNull CharSequence cue)
```

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

A cue can be used as a fallback when `https://developer.android.com/reference/androidx/car/app/navigation/model/Maneuver` is not set or is unavailable.

Some cluster displays do not support UTF-8 encoded characters, in which case unsupported characters will not be displayed properly.

See `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#setCue(java.lang.CharSequence)` for details on span support in the input string.

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

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#setCue(java.lang.CharSequence)` |   |

## Public methods

### addLane

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

```
public @NonNull Step.Builder addLane(@NonNull Lane lane)
```

Adds the information of a single road lane at the point where the driver should execute this step.

Lane information is primarily used when the step is passed to the vehicle cluster or heads up displays. Some vehicles may not use the information at all. The navigation template primarily uses the lanes image provided in `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#setLanesImage(androidx.car.app.model.CarIcon)`.

Lanes are displayed from left to right.

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

### build

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

```
public @NonNull Step build()
```

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

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if `lanesImage` was set but no lanes were added |

### setCue

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

```
public @NonNull Step.Builder setCue(@NonNull CharSequence cue)
```

Sets a text description of this maneuver.

A cue can be used as a fallback when `https://developer.android.com/reference/androidx/car/app/navigation/model/Maneuver` is not set or is unavailable.

For example "Turn left", "Make a U-Turn", "Sharp Right", or "Take the exit using the left lane"

The `cue` string can contain `https://developer.android.com/reference/androidx/car/app/model/CarIconSpan`s, `https://developer.android.com/reference/androidx/car/app/model/DistanceSpan`s, and `https://developer.android.com/reference/androidx/car/app/model/DurationSpan`s.

In the following example, the "520" text is replaced with an icon:

```
SpannableString string = new SpannableString("Turn right on 520 East");
string.setSpan(textWithImage.setSpan(
    CarIconSpan.create(new CarIcon.Builder(
        IconCompat.createWithResource(getCarContext(), R.drawable.ic_520_highway))),
        14, 17, SPAN_INCLUSIVE_EXCLUSIVE));
```

The host may choose to display the string without the images, so it is important that the string content is readable without the images. This may be the case, for example, if the string is sent to a cluster display that does not support images, or if the host limits the number of images that may be allowed for one line of text.

#### Image Sizing Guidance

The size these images will be displayed at varies depending on where the `https://developer.android.com/reference/androidx/car/app/navigation/model/Step` object is used. Refer to the documentation of those APIs for details.

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 `cue` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `cue` contains unsupported spans |

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

### setLanesImage

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

```
public @NonNull Step.Builder setLanesImage(@NonNull CarIcon lanesImage)
```

Sets an image representing all the lanes.

This image takes priority over `https://developer.android.com/reference/androidx/car/app/navigation/model/Lane`s that may have been added with `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#addLane(androidx.car.app.navigation.model.Lane)`. If an image is added for the lanes with this method then corresponding lane data using `https://developer.android.com/reference/androidx/car/app/navigation/model/Step.Builder#addLane(androidx.car.app.navigation.model.Lane)` must also have been added in case it is shown on a display with limited resources such as the car cluster or heads-up display (HUD).

This image should ideally have a transparent background.

#### Image Sizing Guidance

To minimize scaling artifacts across a wide range of car screens, apps should provide images targeting a 500 x 74 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.

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

### setManeuver

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

```
public @NonNull Step.Builder setManeuver(@NonNull Maneuver maneuver)
```

Sets the maneuver to be performed on this step.

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

### setRoad

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

```
public @NonNull Step.Builder setRoad(@NonNull CharSequence road)
```

Sets a text description of the road for the step.

This value is primarily used for vehicle cluster and heads-up displays and may not appear in the navigation template.

For example, a `https://developer.android.com/reference/androidx/car/app/navigation/model/Step` for a left turn might provide "State Street" for the road.

Only `https://developer.android.com/reference/androidx/car/app/model/DistanceSpan`s and `https://developer.android.com/reference/androidx/car/app/model/DurationSpan`s are supported in the input string.

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

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