Stay organized with collections Save and categorize content based on your preferences.

SliceItem

@RequiresApi(value = 19)
public final class SliceItem implements VersionedParcelable


A SliceItem is a single unit in the tree structure of a Slice.

A SliceItem a piece of content and some hints about what that content means or how it should be displayed. The types of content can be:

The hints that a SliceItem are a set of strings which annotate the content. The hints that are guaranteed to be understood by the system are defined on Slice.

Summary

Public methods

static @NonNull ParcelableSpan

Creates a span object that identifies content that should be redacted when acquired using getRedactedText.

void

Trigger the action on this SliceItem.

PendingIntent
String

Get the format of this SliceItem.

@NonNull List<String>

Gets all hints associated with this SliceItem.

IconCompat
int
long
@Nullable CharSequence

Get the same content as getText except with content that should be excluded from persistent logs because it was tagged with createSensitiveSpan.

Slice
String

Get the sub-type of this SliceItem.

CharSequence
boolean
String

Public methods

createSensitiveSpan

public static @NonNull ParcelableSpan createSensitiveSpan()

Creates a span object that identifies content that should be redacted when acquired using getRedactedText.

fireAction

public void fireAction(@Nullable Context context, @Nullable Intent i)

Trigger the action on this SliceItem.

Parameters
@Nullable Context context

The Context to use when sending the PendingIntent.

@Nullable Intent i

The intent to use when sending the PendingIntent.

Throws
android.app.PendingIntent.CanceledException android.app.PendingIntent.CanceledException

getAction

public PendingIntent getAction()
Returns
PendingIntent

The pending intent held by this FORMAT_ACTION SliceItem

getFormat

public String getFormat()

Get the format of this SliceItem.

The format will be one of the following types supported by the platform:

See also
getSubType

()

getHints

public @NonNull List<StringgetHints()

Gets all hints associated with this SliceItem.

Returns
@NonNull List<String>

Array of hints.

getIcon

public IconCompat getIcon()
Returns
IconCompat

The icon held by this FORMAT_IMAGE SliceItem

getInt

public int getInt()
Returns
int

The color held by this FORMAT_INT SliceItem

getLong

public long getLong()
Returns
long

The long held by this FORMAT_LONG SliceItem

getRedactedText

public @Nullable CharSequence getRedactedText()

Get the same content as getText except with content that should be excluded from persistent logs because it was tagged with createSensitiveSpan.

Returns
@Nullable CharSequence

The text held by this FORMAT_TEXT SliceItem

getSlice

public Slice getSlice()
Returns
Slice

The slice held by this FORMAT_ACTION or FORMAT_SLICE SliceItem

getSubType

public String getSubType()

Get the sub-type of this SliceItem.

Subtypes provide additional information about the type of this information beyond basic interpretations inferred by getFormat. For example a slice may contain many FORMAT_TEXT items, but only some of them may be SUBTYPE_MESSAGE.

See also
getFormat

getText

public CharSequence getText()
Returns
CharSequence

The text held by this FORMAT_TEXT SliceItem

hasHint

public boolean hasHint(String hint)
Parameters
String hint

The hint to check for

Returns
boolean

true if this item contains the given hint

toString

public String toString()
Returns
String

A string representation of this slice item.