Suggestion.Builder


public final class Suggestion.Builder


A builder of Suggestion.

Summary

Public constructors

Returns an empty Builder instance.

Public methods

@NonNull Suggestion

Constructs the Suggestion defined by this builder.

@NonNull Suggestion.Builder

Sets the PendingIntent for the suggestion action.

@NonNull Suggestion.Builder

Sets a suggestion image to display.

@NonNull Suggestion.Builder

Sets the suggestion identifier.

@NonNull Suggestion.Builder

Sets the suggestion subtitle formatted for the user's current locale.

@NonNull Suggestion.Builder

Sets the suggestion title formatted for the user's current locale.

Public constructors

Builder

Added in 1.3.0
public Builder()

Returns an empty Builder instance.

Public methods

build

Added in 1.3.0
public @NonNull Suggestion build()

Constructs the Suggestion defined by this builder.

Throws
java.lang.IllegalStateException

if any of the files are null or if the title and the subtitle are empty.

setAction

Added in 1.3.0
public @NonNull Suggestion.Builder setAction(@NonNull PendingIntent action)

Sets the PendingIntent for the suggestion action.

Throws
java.lang.NullPointerException

if pendingIntent is null

setIcon

Added in 1.3.0
public @NonNull Suggestion.Builder setIcon(@NonNull CarIcon icon)

Sets a suggestion image to display.

Image Sizing Guidance To minimize scaling artifacts across a wide range of car screens, apps should provide images targeting a 128 x 128 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 the aspect ratio. Icon images are expected to be tintable.

See CarIcon for more details related to providing icon and image resources that work with different car screen pixel densities.

Throws
java.lang.NullPointerException

if image is null

setIdentifier

Added in 1.3.0
public @NonNull Suggestion.Builder setIdentifier(@NonNull String identifier)

Sets the suggestion identifier.

Throws
java.lang.NullPointerException

if identifier is null

setSubtitle

Added in 1.3.0
public @NonNull Suggestion.Builder setSubtitle(@NonNull CharSequence subtitle)

Sets the suggestion subtitle formatted for the user's current locale.

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

Throws
java.lang.NullPointerException

if subtitle is null

See also
CarText

setTitle

Added in 1.3.0
public @NonNull Suggestion.Builder setTitle(@NonNull CharSequence title)

Sets the suggestion title formatted for the user's current locale.

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

Throws
java.lang.NullPointerException

if title is null

See also
CarText