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
void

Called immediately after this object has been deserialized, can be used to handle any custom fields that cannot be easily annotated.

void
onPreParceling(boolean isStream)

Called immediately before this object is going to be serialized, can be used to handle any custom fields that cannot be easily annotated.

String

Public methods

createSensitiveSpan

Added in 1.1.0-alpha02
public static @NonNull ParcelableSpan createSensitiveSpan()

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

fireAction

Added in 1.1.0-alpha02
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.

getAction

Added in 1.1.0-alpha02
public PendingIntent getAction()
Returns
PendingIntent

The pending intent held by this FORMAT_ACTION SliceItem

getFormat

Added in 1.1.0-alpha02
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

Added in 1.1.0-alpha02
public @NonNull List<StringgetHints()

Gets all hints associated with this SliceItem.

Returns
@NonNull List<String>

Array of hints.

getIcon

Added in 1.1.0-alpha02
public IconCompat getIcon()
Returns
IconCompat

The icon held by this FORMAT_IMAGE SliceItem

getInt

Added in 1.1.0-alpha02
public int getInt()
Returns
int

The color held by this FORMAT_INT SliceItem

getLong

Added in 1.1.0-alpha02
public long getLong()
Returns
long

The long held by this FORMAT_LONG SliceItem

getRedactedText

Added in 1.1.0-alpha02
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

Added in 1.1.0-alpha02
public Slice getSlice()
Returns
Slice

The slice held by this FORMAT_ACTION or FORMAT_SLICE SliceItem

getSubType

Added in 1.1.0-alpha02
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

Added in 1.1.0-alpha02
public CharSequence getText()
Returns
CharSequence

The text held by this FORMAT_TEXT SliceItem

hasHint

Added in 1.1.0-alpha02
public boolean hasHint(String hint)
Parameters
String hint

The hint to check for

Returns
boolean

true if this item contains the given hint

onPostParceling

Added in 1.1.0-alpha02
public void onPostParceling()

Called immediately after this object has been deserialized, can be used to handle any custom fields that cannot be easily annotated.

onPreParceling

Added in 1.1.0-alpha02
public void onPreParceling(boolean isStream)

Called immediately before this object is going to be serialized, can be used to handle any custom fields that cannot be easily annotated.

toString

public String toString()
Returns
String

A string representation of this slice item.