AgentTaskState


public final class AgentTaskState
extends Object implements Parcelable

java.lang.Object
   ↳ android.agenticon.AgentTaskState


Information about the agent's current state. This information is shown as an icon in the status bar.

This icon can be clicked to open the agent application.

Summary

Nested classes

class AgentTaskState.Builder

Builder for AgentTaskState

Inherited constants

Fields

public static final Creator<AgentTaskState> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

PendingIntent getClickAction()

PendingIntent to send when the state icon in the status bar is clicked.

CharSequence getContentDescription()

Content description associated with getIcon().

Icon getIcon()

Icon to display in the status bar.

boolean shouldInterruptPreviousAnimation()

Indicates that this new state's icon should interrupt the animation of the previous state's icon.

boolean shouldLoopAnimation()

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

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Fields

CREATOR

Added in version 37.2
public static final Creator<AgentTaskState> CREATOR

Public methods

describeContents

Added in version 37.2
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(Parcel,int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
Value is either 0 or

getClickAction

Added in version 37.2
public PendingIntent getClickAction ()

PendingIntent to send when the state icon in the status bar is clicked.

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:

Returns
PendingIntent the action to execute when the element is clicked.

getContentDescription

Added in version 37.2
public CharSequence getContentDescription ()

Content description associated with getIcon().

This content description will be concatenated with the application name, and may be hidden in sensitive contexts.

Returns
CharSequence a description of the icon.
This value cannot be null.

getIcon

Added in version 37.2
public Icon getIcon ()

Icon to display in the status bar.

This icon will be used until the next AgentTaskState is sent.

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

The icon can be an animation. Icon animations are recommended to be finite and less than 3 seconds in length. Longer animations may be cut short depending on system constraints.

If the provided animation should loop on repeat, ERROR(/#shouldLoopAnimtion()) should be set to true.

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 shouldInterruptPreviousAnimation() set to true.

Returns
Icon the icon representing the current state of the agent.
This value cannot be null.

shouldInterruptPreviousAnimation

Added in version 37.2
public boolean shouldInterruptPreviousAnimation ()

Indicates that this new state's icon should interrupt the animation of the previous state's icon.

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.

Returns
boolean true if this state's icon should interrupt the previous state's animation, instead of playing it until completion.

shouldLoopAnimation

Added in version 37.2
public boolean shouldLoopAnimation ()

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

If this value is true:

  • If the icon provided in 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 shouldInterruptPreviousAnimation() set to true.
  • If the icon provided in 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 getIcon() is not animated, this value is ignored.

If this value is false:

  • If the icon provided in 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 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 getIcon() is not animated, this value is ignored.

Returns
boolean true if this state's icon should continue looping as long as is allowed by the system.

writeToParcel

Added in version 37.2
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.
Value is either 0 or a combination of the following: