belongs to Maven artifact androidx.slice:slice-core:1.0.0-alpha1

SliceItem

public class SliceItem
extends Object

java.lang.Object
   ↳ 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:

  • SliceItem.FORMAT_SLICE
  • SliceItem.FORMAT_TEXT
  • SliceItem.FORMAT_IMAGE
  • SliceItem.FORMAT_ACTION
  • SliceItem.FORMAT_INT
  • SliceItem.FORMAT_TIMESTAMP
  • 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

    PendingIntent getAction()
    String getFormat()

    Get the format of this SliceItem.

    List<String> getHints()

    Gets all hints associated with this SliceItem.

    IconCompat getIcon()
    int getInt()
    long getLong()
    Slice getSlice()
    String getSubType()

    Get the sub-type of this SliceItem.

    CharSequence getText()
    long getTimestamp()

    This method is deprecated. TO BE REMOVED

    boolean hasHint(String hint)
    String toString()

    Inherited methods

    Public methods

    getAction

    PendingIntent getAction ()

    Returns
    PendingIntent The pending intent held by this SliceItem.FORMAT_ACTION SliceItem

    getFormat

    String getFormat ()

    Get the format of this SliceItem.

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

  • SliceItem.FORMAT_SLICE
  • SliceItem.FORMAT_TEXT
  • SliceItem.FORMAT_IMAGE
  • SliceItem.FORMAT_ACTION
  • SliceItem.FORMAT_INT
  • SliceItem.FORMAT_TIMESTAMP
  • SliceItem.FORMAT_REMOTE_INPUT
  • Returns
    String

    See also:

    getHints

    List<String> getHints ()

    Gets all hints associated with this SliceItem.

    Returns
    List<String> Array of hints.

    getIcon

    IconCompat getIcon ()

    Returns
    IconCompat The icon held by this SliceItem.FORMAT_IMAGE SliceItem

    getInt

    int getInt ()

    Returns
    int The color held by this SliceItem.FORMAT_INT SliceItem

    getLong

    long getLong ()

    Returns
    long The long held by this SliceItem.FORMAT_LONG SliceItem

    getSlice

    Slice getSlice ()

    Returns
    Slice The slice held by this SliceItem.FORMAT_ACTION or SliceItem.FORMAT_SLICE SliceItem

    getSubType

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

    Returns
    String

    See also:

    getText

    CharSequence getText ()

    Returns
    CharSequence The text held by this SliceItem.FORMAT_TEXT SliceItem

    getTimestamp

    long getTimestamp ()

    This method is deprecated.
    TO BE REMOVED

    Returns
    long

    hasHint

    boolean hasHint (String hint)

    Parameters
    hint String: The hint to check for

    Returns
    boolean true if this item contains the given hint

    toString

    String toString ()

    Returns
    String A string representation of this slice item.