SliceItem

public final class SliceItem
extends CustomVersionedParcelable

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

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

    void fireAction(Context context, Intent i)

    Trigger the action on this SliceItem.

    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()
    boolean hasHint(String hint)
    void onPostParceling()
    void onPreParceling(boolean isStream)
    String toString()

    Inherited methods

    Public methods

    fireAction

    public void fireAction (Context context, 
                    Intent i)

    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.

    Throws
    PendingIntent.CanceledException

    getAction

    public PendingIntent getAction ()

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

    getFormat

    public 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_LONG
  • SliceItem.FORMAT_REMOTE_INPUT
  • Returns
    String

    See also:

    getHints

    public List<String> getHints ()

    Gets all hints associated with this SliceItem.

    Returns
    List<String> Array of hints.

    getIcon

    public IconCompat getIcon ()

    Returns
    IconCompat The icon held by this SliceItem.FORMAT_IMAGE SliceItem

    getInt

    public int getInt ()

    Returns
    int The color held by this SliceItem.FORMAT_INT SliceItem

    getLong

    public long getLong ()

    Returns
    long The long held by this SliceItem.FORMAT_LONG SliceItem

    getSlice

    public Slice getSlice ()

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

    getSubType

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

    Returns
    String

    See also:

    getText

    public CharSequence getText ()

    Returns
    CharSequence The text held by this SliceItem.FORMAT_TEXT SliceItem

    hasHint

    public boolean hasHint (String hint)

    Parameters
    hint String: The hint to check for

    Returns
    boolean true if this item contains the given hint

    onPostParceling

    public void onPostParceling ()

    onPreParceling

    public void onPreParceling (boolean isStream)

    Parameters
    isStream boolean

    toString

    public String toString ()

    Returns
    String A string representation of this slice item.