lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

belongs to Maven artifact androidx.slice:slice-builders:1.0.0-alpha3

SliceAction

public class SliceAction
extends Object implements SliceAction

java.lang.Object
   ↳ androidx.slice.builders.SliceAction


Class representing an action, supports tappable icons, custom toggle icons, and default toggles.

Summary

Public constructors

SliceAction(PendingIntent action, Icon actionIcon, CharSequence actionTitle)

This constructor is deprecated. TO BE REMOVED

SliceAction(PendingIntent action, Icon actionIcon, int imageMode, CharSequence actionTitle)

This constructor is deprecated. TO BE REMOVED

SliceAction(PendingIntent action, Icon actionIcon, CharSequence actionTitle, boolean isChecked)

This constructor is deprecated. TO BE REMOVED

SliceAction(PendingIntent action, IconCompat actionIcon, CharSequence actionTitle)

Construct a SliceAction representing a tappable icon.

SliceAction(PendingIntent action, IconCompat actionIcon, int imageMode, CharSequence actionTitle)

Construct a SliceAction representing a tappable icon.

SliceAction(PendingIntent action, IconCompat actionIcon, CharSequence actionTitle, boolean isChecked)

Construct a SliceAction representing a custom toggle icon.

SliceAction(PendingIntent action, CharSequence actionTitle, boolean isChecked)

Construct a SliceAction representing a default toggle.

Public methods

PendingIntent getAction()
CharSequence getContentDescription()
IconCompat getIcon()
int getImageMode()
int getPriority()
CharSequence getTitle()
boolean isChecked()
boolean isDefaultToggle()
boolean isToggle()
SliceAction setChecked(boolean isChecked)
SliceAction setContentDescription(CharSequence description)
SliceAction setPriority(int priority)

Sets the priority of this action, with the lowest priority having the highest ranking.

Inherited methods

Public constructors

SliceAction

public SliceAction (PendingIntent action, 
                Icon actionIcon, 
                CharSequence actionTitle)

This constructor is deprecated.
TO BE REMOVED

Parameters
action PendingIntent

actionIcon Icon

actionTitle CharSequence

SliceAction

public SliceAction (PendingIntent action, 
                Icon actionIcon, 
                int imageMode, 
                CharSequence actionTitle)

This constructor is deprecated.
TO BE REMOVED

Parameters
action PendingIntent

actionIcon Icon

imageMode int

actionTitle CharSequence

SliceAction

public SliceAction (PendingIntent action, 
                Icon actionIcon, 
                CharSequence actionTitle, 
                boolean isChecked)

This constructor is deprecated.
TO BE REMOVED

Parameters
action PendingIntent

actionIcon Icon

actionTitle CharSequence

isChecked boolean

SliceAction

public SliceAction (PendingIntent action, 
                IconCompat actionIcon, 
                CharSequence actionTitle)

Construct a SliceAction representing a tappable icon.

Parameters
action PendingIntent: the pending intent to invoke for this action.

actionIcon IconCompat: the icon to display for this action.

actionTitle CharSequence: the title for this action, also used for content description if one hasn't been set via setContentDescription(CharSequence).

SliceAction

public SliceAction (PendingIntent action, 
                IconCompat actionIcon, 
                int imageMode, 
                CharSequence actionTitle)

Construct a SliceAction representing a tappable icon. Use this method to specify the format of the image, ListBuilder.ICON_IMAGE will be presented as a tintable icon. Note that there is no difference between ListBuilder.SMALL_IMAGE and ListBuilder.LARGE_IMAGE for actions; these will just be represented as an non-tintable image.

Parameters
action PendingIntent: the pending intent to invoke for this action.

actionIcon IconCompat: the icon to display for this action.

imageMode int: the mode this icon should be displayed in.

actionTitle CharSequence: the title for this action, also used for content description if one hasn't been set via setContentDescription(CharSequence).

SliceAction

public SliceAction (PendingIntent action, 
                IconCompat actionIcon, 
                CharSequence actionTitle, 
                boolean isChecked)

Construct a SliceAction representing a custom toggle icon.

Parameters
action PendingIntent: the pending intent to invoke for this toggle.

actionIcon IconCompat: the icon to display for this toggle, should have a checked and unchecked state.

actionTitle CharSequence: the title for this toggle, also used for content description if one hasn't been set via setContentDescription(CharSequence).

isChecked boolean: the state of the toggle.

SliceAction

public SliceAction (PendingIntent action, 
                CharSequence actionTitle, 
                boolean isChecked)

Construct a SliceAction representing a default toggle.

Parameters
action PendingIntent: the pending intent to invoke for this toggle.

actionTitle CharSequence: the title for this toggle, also used for content description if one hasn't been set via setContentDescription(CharSequence).

isChecked boolean: the state of the toggle.

Public methods

getAction

public PendingIntent getAction ()

Returns
PendingIntent the PendingIntent associated with this action.

getContentDescription

public CharSequence getContentDescription ()

Returns
CharSequence the content description to use for this action.

getIcon

public IconCompat getIcon ()

Returns
IconCompat the Icon to display for this action. This can be null when the action represented is a default toggle.

getImageMode

public int getImageMode ()

Returns
int the image mode to use for this action.

getPriority

public int getPriority ()

Returns
int the priority associated with this action, -1 if unset.

getTitle

public CharSequence getTitle ()

Returns
CharSequence the title for this action.

isChecked

public boolean isChecked ()

Returns
boolean whether the state of this action is checked or not; only used for toggle actions.

isDefaultToggle

public boolean isDefaultToggle ()

Returns
boolean whether this action is a toggle using the standard switch control.

isToggle

public boolean isToggle ()

Returns
boolean whether this action represents a toggle (i.e. has a checked and unchecked state).

setChecked

public SliceAction setChecked (boolean isChecked)

Parameters
isChecked boolean: whether the state of this action is checked or not; only used for toggle actions.

Returns
SliceAction

setContentDescription

public SliceAction setContentDescription (CharSequence description)

Parameters
description CharSequence: the content description for this action.

Returns
SliceAction

setPriority

public SliceAction setPriority (int priority)

Sets the priority of this action, with the lowest priority having the highest ranking.

Parameters
priority int

Returns
SliceAction