SliceAction
@RequiresApi(value = 19)
public class SliceAction implements SliceAction
Class representing an action, supports tappable icons, custom toggle icons, and default toggles, as well as date and time pickers.
Summary
Public methods |
|
|---|---|
static SliceAction |
create(Construct a SliceAction representing a tappable icon. |
static SliceAction |
create(Construct a SliceAction representing a tappable icon. |
static SliceAction |
createDeeplink(Construct a SliceAction representing a tappable icon that launches an activity when clicked. |
static SliceAction |
createDeeplink(Construct a SliceAction representing a tappable icon that launches an activity when clicked. |
static SliceAction |
createToggle(Construct a SliceAction representing a default toggle. |
static SliceAction |
createToggle(Construct a SliceAction representing a default toggle. |
static SliceAction |
createToggle(Construct a SliceAction representing a custom toggle icon. |
static SliceAction |
createToggle(Construct a SliceAction representing a custom toggle icon. |
@NonNull PendingIntent |
|
@Nullable CharSequence |
|
@Nullable IconCompat |
getIcon() |
int |
|
int |
|
@NonNull CharSequence |
getTitle() |
boolean |
|
boolean |
|
boolean |
|
boolean |
isToggle() |
@NonNull SliceAction |
setChecked(boolean isChecked) |
@NonNull SliceAction |
setContentDescription(@NonNull CharSequence description) |
@NonNull SliceAction |
setPriority(@IntRange(from = 0) int priority)Sets the priority of this action, with the lowest priority having the highest ranking. |
Public methods
create
public static SliceAction create(
@NonNull PendingIntent action,
@NonNull IconCompat actionIcon,
int imageMode,
@NonNull CharSequence actionTitle
)
Construct a SliceAction representing a tappable icon.
| Parameters | |
|---|---|
@NonNull PendingIntent action |
the pending intent to invoke for this action. |
@NonNull IconCompat actionIcon |
the icon to display for this action. |
int imageMode |
the mode this icon should be displayed in. |
@NonNull CharSequence actionTitle |
the title for this action, also used for content description if one hasn't been set via |
| See also | |
|---|---|
ICON_IMAGE |
|
SMALL_IMAGE |
|
LARGE_IMAGE |
create
public static SliceAction create(
@NonNull RemoteCallback action,
@NonNull IconCompat actionIcon,
int imageMode,
@NonNull CharSequence actionTitle
)
Construct a SliceAction representing a tappable icon.
| Parameters | |
|---|---|
@NonNull RemoteCallback action |
the remote callback to invoke for this action. |
@NonNull IconCompat actionIcon |
the icon to display for this action. |
int imageMode |
the mode this icon should be displayed in. |
@NonNull CharSequence actionTitle |
the title for this action, also used for content description if one hasn't been set via |
| See also | |
|---|---|
ICON_IMAGE |
|
SMALL_IMAGE |
|
LARGE_IMAGE |
createDeeplink
public static SliceAction createDeeplink(
@NonNull PendingIntent action,
@NonNull IconCompat actionIcon,
int imageMode,
@NonNull CharSequence actionTitle
)
Construct a SliceAction representing a tappable icon that launches an activity when clicked.
| Parameters | |
|---|---|
@NonNull PendingIntent action |
the pending intent to invoke for this action. |
@NonNull IconCompat actionIcon |
the icon to display for this action. |
int imageMode |
the mode this icon should be displayed in. |
@NonNull CharSequence actionTitle |
the title for this action, also used for content description if one hasn't been set via |
| See also | |
|---|---|
ICON_IMAGE |
|
SMALL_IMAGE |
|
LARGE_IMAGE |
createDeeplink
public static SliceAction createDeeplink(
@NonNull RemoteCallback action,
@NonNull IconCompat actionIcon,
int imageMode,
@NonNull CharSequence actionTitle
)
Construct a SliceAction representing a tappable icon that launches an activity when clicked.
| Parameters | |
|---|---|
@NonNull RemoteCallback action |
the remote callback to invoke for this action. |
@NonNull IconCompat actionIcon |
the icon to display for this action. |
int imageMode |
the mode this icon should be displayed in. |
@NonNull CharSequence actionTitle |
the title for this action, also used for content description if one hasn't been set via |
| See also | |
|---|---|
ICON_IMAGE |
|
SMALL_IMAGE |
|
LARGE_IMAGE |
createToggle
public static SliceAction createToggle(
@NonNull PendingIntent action,
@NonNull CharSequence actionTitle,
boolean isChecked
)
Construct a SliceAction representing a default toggle.
| Parameters | |
|---|---|
@NonNull PendingIntent action |
the pending intent to invoke for this toggle. |
@NonNull CharSequence actionTitle |
the title for this toggle, also used for content description if one hasn't been set via |
boolean isChecked |
the state of the toggle. |
createToggle
public static SliceAction createToggle(
@NonNull RemoteCallback action,
@NonNull CharSequence actionTitle,
boolean isChecked
)
Construct a SliceAction representing a default toggle.
| Parameters | |
|---|---|
@NonNull RemoteCallback action |
the remote callback to invoke for this toggle. |
@NonNull CharSequence actionTitle |
the title for this toggle, also used for content description if one hasn't been set via |
boolean isChecked |
the state of the toggle. |
createToggle
public static SliceAction createToggle(
@NonNull PendingIntent action,
@NonNull IconCompat actionIcon,
@NonNull CharSequence actionTitle,
boolean isChecked
)
Construct a SliceAction representing a custom toggle icon.
| Parameters | |
|---|---|
@NonNull PendingIntent action |
the pending intent to invoke for this toggle. |
@NonNull IconCompat actionIcon |
the icon to display for this toggle, should have a checked and unchecked state. |
@NonNull CharSequence actionTitle |
the title for this toggle, also used for content description if one hasn't been set via |
boolean isChecked |
the state of the toggle. |
createToggle
public static SliceAction createToggle(
@NonNull RemoteCallback action,
@NonNull IconCompat actionIcon,
@NonNull CharSequence actionTitle,
boolean isChecked
)
Construct a SliceAction representing a custom toggle icon.
| Parameters | |
|---|---|
@NonNull RemoteCallback action |
the remote callback to invoke for this toggle. |
@NonNull IconCompat actionIcon |
the icon to display for this toggle, should have a checked and unchecked state. |
@NonNull CharSequence actionTitle |
the title for this toggle, also used for content description if one hasn't been set via |
boolean isChecked |
the state of the toggle. |
getAction
public @NonNull PendingIntent getAction()
| Returns | |
|---|---|
@NonNull PendingIntent |
the |
getContentDescription
public @Nullable CharSequence getContentDescription()
| Returns | |
|---|---|
@Nullable CharSequence |
the content description to use for this action. |
getIcon
public @Nullable IconCompat getIcon()
| Returns | |
|---|---|
@Nullable IconCompat |
the |
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 @NonNull CharSequence getTitle()
| Returns | |
|---|---|
@NonNull CharSequence |
the title for this action. |
isActivity
public boolean isActivity()
| Returns | |
|---|---|
boolean |
whether this activity launches an activity or not. |
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 @NonNull SliceAction setChecked(boolean isChecked)
| Parameters | |
|---|---|
boolean isChecked |
whether the state of this action is checked or not; only used for toggle actions. |
setContentDescription
public @NonNull SliceAction setContentDescription(@NonNull CharSequence description)
| Parameters | |
|---|---|
@NonNull CharSequence description |
the content description for this action. |
setPriority
public @NonNull SliceAction setPriority(@IntRange(from = 0) int priority)
Sets the priority of this action, with the lowest priority having the highest ranking.