Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 1.0.0
belongs to Maven artifact androidx.slice:slice-builders:1.0.0-rc01

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 methods

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

Construct a SliceAction representing a tappable icon.

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

Construct a SliceAction representing a tappable icon that launches an activity when clicked.

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

Construct a SliceAction representing a custom toggle icon.

static SliceAction createToggle(PendingIntent action, CharSequence actionTitle, boolean isChecked)

Construct a SliceAction representing a default toggle.

PendingIntent getAction()
CharSequence getContentDescription()
IconCompat getIcon()
int getImageMode()
int getPriority()
CharSequence getTitle()
boolean isActivity()
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 methods

create

added in version 1.0.0
public static SliceAction create (PendingIntent action, 
                IconCompat actionIcon, 
                int imageMode, 
                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.

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).

Returns
SliceAction

createDeeplink

added in version 1.0.0
public static SliceAction createDeeplink (PendingIntent action, 
                IconCompat actionIcon, 
                int imageMode, 
                CharSequence actionTitle)

Construct a SliceAction representing a tappable icon that launches an activity when clicked.

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).

Returns
SliceAction

createToggle

added in version 1.0.0
public static SliceAction createToggle (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.

Returns
SliceAction

createToggle

added in version 1.0.0
public static SliceAction createToggle (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.

Returns
SliceAction

getAction

added in version 1.0.0
public PendingIntent getAction ()

Returns
PendingIntent the PendingIntent associated with this action.

getContentDescription

added in version 1.0.0
public CharSequence getContentDescription ()

Returns
CharSequence the content description to use for this action.

getIcon

added in version 1.0.0
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

added in version 1.0.0
public int getImageMode ()

Returns
int the image mode to use for this action.

getPriority

added in version 1.0.0
public int getPriority ()

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

getTitle

added in version 1.0.0
public CharSequence getTitle ()

Returns
CharSequence the title for this action.

isActivity

added in version 1.0.0
public boolean isActivity ()

Returns
boolean

isChecked

added in version 1.0.0
public boolean isChecked ()

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

isDefaultToggle

added in version 1.0.0
public boolean isDefaultToggle ()

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

isToggle

added in version 1.0.0
public boolean isToggle ()

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

setChecked

added in version 1.0.0
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

added in version 1.0.0
public SliceAction setContentDescription (CharSequence description)

Parameters
description CharSequence: the content description for this action.

Returns
SliceAction

setPriority

added in version 1.0.0
public SliceAction setPriority (int priority)

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

Parameters
priority int

Returns
SliceAction