Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

SliceItem

class SliceItem : CustomVersionedParcelable
androidx.slice.SliceItem

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:

  • android.app.slice.SliceItem#FORMAT_SLICE
  • android.app.slice.SliceItem#FORMAT_TEXT
  • android.app.slice.SliceItem#FORMAT_IMAGE
  • android.app.slice.SliceItem#FORMAT_ACTION
  • android.app.slice.SliceItem#FORMAT_INT
  • android.app.slice.SliceItem#FORMAT_LONG
  • 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 ParcelableSpan

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

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

    Trigger the action on this SliceItem.

    PendingIntent!

    String!

    Get the format of this SliceItem.

    MutableList<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

    Unit

    String

    Public methods

    createSensitiveSpan

    @NonNull static fun createSensitiveSpan(): ParcelableSpan

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

    fireAction

    fun fireAction(@Nullable context: Context?, @Nullable i: Intent?): Unit

    Trigger the action on this SliceItem.

    Parameters
    context Context?: The Context to use when sending the PendingIntent.
    i Context?: The intent to use when sending the PendingIntent.

    getAction

    fun getAction(): PendingIntent!
    Return
    PendingIntent!: The pending intent held by this android.app.slice.SliceItem#FORMAT_ACTION SliceItem

    getHints

    @NonNull fun getHints(): MutableList<String!>

    Gets all hints associated with this SliceItem.

    Return
    MutableList<String!>: Array of hints.

    getIcon

    fun getIcon(): IconCompat!
    Return
    IconCompat!: The icon held by this android.app.slice.SliceItem#FORMAT_IMAGE SliceItem

    getInt

    fun getInt(): Int
    Return
    Int: The color held by this android.app.slice.SliceItem#FORMAT_INT SliceItem

    getLong

    fun getLong(): Long
    Return
    Long: The long held by this android.app.slice.SliceItem#FORMAT_LONG SliceItem

    getRedactedText

    @Nullable 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().

    Return
    CharSequence?: The text held by this android.app.slice.SliceItem#FORMAT_TEXT SliceItem

    getSlice

    fun getSlice(): Slice!
    Return
    Slice!: The slice held by this android.app.slice.SliceItem#FORMAT_ACTION or android.app.slice.SliceItem#FORMAT_SLICE SliceItem

    getSubType

    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 android.app.slice.SliceItem#FORMAT_TEXT items, but only some of them may be android.app.slice.Slice#SUBTYPE_MESSAGE.

    See Also

    getText

    fun getText(): CharSequence!
    Return
    CharSequence!: The text held by this android.app.slice.SliceItem#FORMAT_TEXT SliceItem

    hasHint

    fun hasHint(hint: String!): Boolean
    Parameters
    hint String!: The hint to check for
    Return
    Boolean: true if this item contains the given hint

    onPostParceling

    fun onPostParceling(): Unit

    onPreParceling

    fun onPreParceling(isStream: Boolean): Unit

    toString

    fun toString(): String
    Return
    String: A string representation of this slice item.