SliceItem


@RequiresApi(value = 19)
class SliceItem : 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 functions

java-static ParcelableSpan

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

Unit
fireAction(context: Context?, i: Intent?)

Trigger the action on this SliceItem.

PendingIntent!
String!

Get the format of this SliceItem.

(Mutable)List<String!>

Gets all hints associated with this SliceItem.

IconCompat!
Int
Long
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
hasHint(hint: String!)
Unit

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

Unit

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 functions

createSensitiveSpan

Added in 1.1.0-alpha02
java-static fun createSensitiveSpan(): ParcelableSpan

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

fireAction

Added in 1.1.0-alpha02
fun fireAction(context: Context?, i: Intent?): Unit

Trigger the action on this SliceItem.

Parameters
context: Context?

The Context to use when sending the PendingIntent.

i: Intent?

The intent to use when sending the PendingIntent.

getAction

Added in 1.1.0-alpha02
fun getAction(): PendingIntent!
Returns
PendingIntent!

The pending intent held by this FORMAT_ACTION SliceItem

getFormat

Added in 1.1.0-alpha02
fun getFormat(): String!

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
fun getHints(): (Mutable)List<String!>

Gets all hints associated with this SliceItem.

Returns
(Mutable)List<String!>

Array of hints.

getIcon

Added in 1.1.0-alpha02
fun getIcon(): IconCompat!
Returns
IconCompat!

The icon held by this FORMAT_IMAGE SliceItem

getInt

Added in 1.1.0-alpha02
fun getInt(): Int
Returns
Int

The color held by this FORMAT_INT SliceItem

getLong

Added in 1.1.0-alpha02
fun getLong(): Long
Returns
Long

The long held by this FORMAT_LONG SliceItem

getRedactedText

Added in 1.1.0-alpha02
fun getRedactedText(): CharSequence?

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

Returns
CharSequence?

The text held by this FORMAT_TEXT SliceItem

getSlice

Added in 1.1.0-alpha02
fun getSlice(): Slice!
Returns
Slice!

The slice held by this FORMAT_ACTION or FORMAT_SLICE SliceItem

getSubType

Added in 1.1.0-alpha02
fun getSubType(): String!

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
fun getText(): CharSequence!
Returns
CharSequence!

The text held by this FORMAT_TEXT SliceItem

hasHint

Added in 1.1.0-alpha02
fun hasHint(hint: String!): Boolean
Parameters
hint: String!

The hint to check for

Returns
Boolean

true if this item contains the given hint

onPostParceling

Added in 1.1.0-alpha02
fun onPostParceling(): Unit

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
fun onPreParceling(isStream: Boolean): Unit

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

toString

fun toString(): String!
Returns
String!

A string representation of this slice item.