Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

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

    Slice!

    String!

    Get the sub-type of this SliceItem.

    CharSequence!

    Boolean
    hasHint(hint: String!)

    Unit

    Unit

    String

    Public methods

    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

    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.