Join us for ⁠#Android11: The Beta Launch Show on June 3!

InlinePresentationBuilder

@RequiresApi(29) open class InlinePresentationBuilder
kotlin.Any
   ↳ androidx.autofill.InlinePresentationBuilder

Helper class to create Slice for rendering into inline suggestions.

This builder is used by AutofillService and providers to create slices representing their inline suggestions UI.

TODO(b/147116534): Add documentation about UI templating.

Summary

Public constructors

<init>(@NonNull title: CharSequence)

Initializes an InlinePresentationBuilder with title text.

Initializes a an InlinePresentationBuilder.

Public methods

open Slice

Creates a new Slice instance.

open InlinePresentationBuilder
setAction(@NonNull action: PendingIntent)

Sets the action of Slice.

open InlinePresentationBuilder
setEndIcon(@NonNull endIcon: Icon)

Sets the end icon of Slice.

open InlinePresentationBuilder
setStartIcon(@NonNull startIcon: Icon)

Sets the start icon of Slice.

open InlinePresentationBuilder
setSubtitle(@NonNull subtitle: CharSequence)

Sets the subtitle of Slice.

Public constructors

<init>

InlinePresentationBuilder(@NonNull title: CharSequence)

Initializes an InlinePresentationBuilder with title text.

Parameters
title CharSequence: String displayed as title of slice.

<init>

InlinePresentationBuilder()

Initializes a an InlinePresentationBuilder.

Public methods

build

@NonNull open fun build(): Slice

Creates a new Slice instance.

You should not interact with this builder once this method is called.

Return
Slice The built slice.
Exceptions
IllegalStateException if none of the title, subtitle, start icon and end icon is set, or if the subtitle is set without the title.

setAction

@NonNull open fun setAction(@NonNull action: PendingIntent): InlinePresentationBuilder

Sets the action of Slice.

Parameters
action PendingIntent: invoked when the slice is tapped.

setEndIcon

@NonNull open fun setEndIcon(@NonNull endIcon: Icon): InlinePresentationBuilder

Sets the end icon of Slice.

Parameters
endIcon Icon: Icon resource displayed at end of slice.

setStartIcon

@NonNull open fun setStartIcon(@NonNull startIcon: Icon): InlinePresentationBuilder

Sets the start icon of Slice.

Parameters
startIcon Icon: Icon resource displayed at start of slice.

setSubtitle

@NonNull open fun setSubtitle(@NonNull subtitle: CharSequence): InlinePresentationBuilder

Sets the subtitle of Slice.

Parameters
subtitle CharSequence: String displayed as subtitle of slice.