AgentTaskState.Builder


public static final class AgentTaskState.Builder
extends Object

java.lang.Object
   ↳ android.agenticon.AgentTaskState.Builder


Builder for AgentTaskState.

Summary

Public constructors

Builder(AgentTaskState.Builder other)

Creates a new Builder from another Builder.

Builder(Icon icon, CharSequence contentDescription)

Creates a new Builder.

Public methods

AgentTaskState build()

Creates the AgentTaskState instance.

AgentTaskState.Builder setClickAction(PendingIntent action)

Sets the click action.

AgentTaskState.Builder setIconAndContentDescription(Icon icon, CharSequence contentDescription)

Sets the icon and content description.

AgentTaskState.Builder setShouldInterruptPreviousAnimation(boolean shouldInterruptPreviousAnimation)

Sets whether this new state should interrupt the animation from the previous state.

AgentTaskState.Builder setShouldLoopAnimation(boolean shouldLoopAnimation)

Indicates that this state's icon animation should be looped on repeat.

Inherited methods

Public constructors

Builder

Added in version 37.2
public Builder (AgentTaskState.Builder other)

Creates a new Builder from another Builder.

Parameters
other AgentTaskState.Builder: a Builder to copy.
This value cannot be null.

Builder

Added in version 37.2
public Builder (Icon icon, 
                CharSequence contentDescription)

Creates a new Builder.

Parameters
icon Icon: the icon to display.
This value cannot be null.

contentDescription CharSequence: the content description for accessibility.
This value cannot be null.

Public methods

build

Added in version 37.2
public AgentTaskState build ()

Creates the AgentTaskState instance.

Returns
AgentTaskState This value cannot be null.

setClickAction

Added in version 37.2
public AgentTaskState.Builder setClickAction (PendingIntent action)

Sets the click action.

The PendingIntent should target an Activity.

If the PendingIntent was created with PendingIntent.FLAG_MUTABLE, as well as Intent.FILL_IN_SOURCE_BOUNDS, then the source bounds will be filled in with the coordinates on screen of the UI element that triggered this intent.

Based on the value of StatusBarManager.isAgentTaskLaunchSupported(), this value will be used differently by the implementation:

Parameters
action PendingIntent: a PendingIntent targeting an Activity
This value may be null.

Returns
AgentTaskState.Builder this Builder

Throws
IllegalArgumentException if action does not target an Activity.

setIconAndContentDescription

Added in version 37.2
public AgentTaskState.Builder setIconAndContentDescription (Icon icon, 
                CharSequence contentDescription)

Sets the icon and content description.

The icon should be a monochrome icon that will be tinted for contrast purposes.

The icon can be an animation. In that case, the animation must be finite in duration. This animation will be played to completion before switching to the next AgentTaskState. This behavior can be interrupted by sending a new AgentTaskState with AgentTaskState.shouldInterruptPreviousAnimation() set to true.

Infinite animation behavior is unspecified.

Parameters
icon Icon: representing the next state to show.
This value cannot be null.

contentDescription CharSequence: associated with the icon.
This value cannot be null.

Returns
AgentTaskState.Builder this Builder
This value cannot be null.

setShouldInterruptPreviousAnimation

Added in version 37.2
public AgentTaskState.Builder setShouldInterruptPreviousAnimation (boolean shouldInterruptPreviousAnimation)

Sets whether this new state should interrupt the animation from the previous state.

If the previous state's icon is an animation, when this is true, this new AgentTaskState will interrupt that animation, immediately moving to the new state (and icon), without waiting for the previous animation to complete.

If the previous icon is not animated, this value is ignored.

Parameters
shouldInterruptPreviousAnimation boolean: true if this new state's icon should interrupt the animation from the previous state's icon

Returns
AgentTaskState.Builder this Builder
This value cannot be null.

setShouldLoopAnimation

Added in version 37.2
public AgentTaskState.Builder setShouldLoopAnimation (boolean shouldLoopAnimation)

Indicates that this state's icon animation should be looped on repeat.

If this value is true:

  • If the icon provided in AgentTaskState.getIcon() has a finite animation, then the finite animation will be re-played. The amount of repetitions will be determined by the system depending on system health, battery life, and other factors. The icon animation will be played to completion before switching to the next AgentTaskState. This behavior can be interrupted by sending a new AgentTaskState with AgentTaskState.shouldInterruptPreviousAnimation() set to true.
  • If the icon provided in AgentTaskState.getIcon() has a infinite animation, then the infinite animation will be played. The total animation time will be determined by the system depending on system health, battery life, and other factors. When the animation is stopped by the system or when a new AgentTaskState is sent, the infinite animation can be stopped at any frame.
  • If the icon provided in AgentTaskState.getIcon() is not animated, this value is ignored.

If this value is false:

  • If the icon provided in AgentTaskState.getIcon() has a finite animation, then the finite animation will be played once and will be played to the end of the animation, though longer animations may be cut short depending on system constraints.
  • If the icon provided in AgentTaskState.getIcon() has a infinite animation, then the infinite animation will be played for a short period of time, around 3 seconds. When the animation is stopped by the system or when a new AgentTaskState is sent, the infinite animation can be stopped at any frame.
  • If the icon provided in AgentTaskState.getIcon() is not animated, this value is ignored.

Parameters
shouldLoopAnimation boolean

Returns
AgentTaskState.Builder this Builder
This value cannot be null.