SliceItem


public final class SliceItem
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.slice.SliceItem


This class was deprecated in API level 35.
Slice framework has been deprecated, it will not receive any updates from ERROR(/android.os.Build.VANILLA_ICE_CREAM) and forward. If you are looking for a framework that sends displayable data from one app to another, consider using AppSearchManager.

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:

  • FORMAT_SLICE
  • FORMAT_TEXT
  • FORMAT_IMAGE
  • FORMAT_ACTION
  • FORMAT_INT
  • FORMAT_LONG
  • FORMAT_REMOTE_INPUT
  • FORMAT_BUNDLE
  • 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

    Constants

    String FORMAT_ACTION

    A SliceItem that contains a PendingIntent Note: Actions contain 2 pieces of data, In addition to the pending intent, the item contains a Slice that the action applies to.

    String FORMAT_BUNDLE

    A SliceItem that contains a Bundle.

    String FORMAT_IMAGE

    A SliceItem that contains an Icon

    String FORMAT_INT

    A SliceItem that contains an int.

    String FORMAT_LONG

    A SliceItem that contains a long.

    String FORMAT_REMOTE_INPUT

    A SliceItem that contains a RemoteInput.

    String FORMAT_SLICE

    A SliceItem that contains a Slice

    String FORMAT_TEXT

    A SliceItem that contains a CharSequence

    Inherited constants

    Fields

    public static final Creator<SliceItem> CREATOR

    Public methods

    int describeContents()

    Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

    PendingIntent getAction()
    Bundle getBundle()
    String getFormat()

    Get the format of this SliceItem.

    List<String> getHints()

    Gets all hints associated with this SliceItem.

    Icon getIcon()
    int getInt()
    long getLong()
    RemoteInput getRemoteInput()
    Slice getSlice()
    String getSubType()

    Get the sub-type of this SliceItem.

    CharSequence getText()
    boolean hasHint(String hint)
    void writeToParcel(Parcel dest, int flags)

    Flatten this object in to a Parcel.

    Inherited methods

    Constants

    FORMAT_ACTION

    Added in API level 28
    public static final String FORMAT_ACTION

    A SliceItem that contains a PendingIntent Note: Actions contain 2 pieces of data, In addition to the pending intent, the item contains a Slice that the action applies to.

    Constant Value: "action"

    FORMAT_BUNDLE

    Added in API level 28
    public static final String FORMAT_BUNDLE

    A SliceItem that contains a Bundle.

    Constant Value: "bundle"

    FORMAT_IMAGE

    Added in API level 28
    public static final String FORMAT_IMAGE

    A SliceItem that contains an Icon

    Constant Value: "image"

    FORMAT_INT

    Added in API level 28
    public static final String FORMAT_INT

    A SliceItem that contains an int.

    Constant Value: "int"

    FORMAT_LONG

    Added in API level 28
    public static final String FORMAT_LONG

    A SliceItem that contains a long.

    Constant Value: "long"

    FORMAT_REMOTE_INPUT

    Added in API level 28
    public static final String FORMAT_REMOTE_INPUT

    A SliceItem that contains a RemoteInput.

    Constant Value: "input"

    FORMAT_SLICE

    Added in API level 28
    public static final String FORMAT_SLICE

    A SliceItem that contains a Slice

    Constant Value: "slice"

    FORMAT_TEXT

    Added in API level 28
    public static final String FORMAT_TEXT

    A SliceItem that contains a CharSequence

    Constant Value: "text"

    Fields

    CREATOR

    Added in API level 28
    public static final Creator<SliceItem> CREATOR

    Public methods

    describeContents

    Added in API level 28
    public int describeContents ()

    Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

    Returns
    int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

    getAction

    Added in API level 28
    public PendingIntent getAction ()

    Returns
    PendingIntent The pending intent held by this FORMAT_ACTION SliceItem

    getBundle

    Added in API level 28
    public Bundle getBundle ()

    Returns
    Bundle The parcelable held by this FORMAT_BUNDLE SliceItem

    getFormat

    Added in API level 28
    public String getFormat ()

    Get the format of this SliceItem.

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

  • FORMAT_SLICE
  • FORMAT_TEXT
  • FORMAT_IMAGE
  • FORMAT_ACTION
  • FORMAT_INT
  • FORMAT_LONG
  • FORMAT_REMOTE_INPUT
  • FORMAT_BUNDLE
  • Returns
    String

    See also:

    getHints

    Added in API level 28
    public List<String> getHints ()

    Gets all hints associated with this SliceItem.

    Returns
    List<String> Array of hints. This value cannot be null. Value is Slice.HINT_TITLE, Slice.HINT_LIST, Slice.HINT_LIST_ITEM, Slice.HINT_LARGE, Slice.HINT_ACTIONS, Slice.HINT_SELECTED, Slice.HINT_NO_TINT, Slice.HINT_SHORTCUT, android.app.slice.Slice.HINT_TOGGLE, Slice.HINT_HORIZONTAL, Slice.HINT_PARTIAL, Slice.HINT_SEE_MORE, Slice.HINT_KEYWORDS, Slice.HINT_ERROR, Slice.HINT_TTL, Slice.HINT_LAST_UPDATED, or Slice.HINT_PERMISSION_REQUEST

    getIcon

    Added in API level 28
    public Icon getIcon ()

    Returns
    Icon The icon held by this FORMAT_IMAGE SliceItem

    getInt

    Added in API level 28
    public int getInt ()

    Returns
    int The color held by this FORMAT_INT SliceItem

    getLong

    Added in API level 28
    public long getLong ()

    Returns
    long The long held by this FORMAT_LONG SliceItem

    getRemoteInput

    Added in API level 28
    public RemoteInput getRemoteInput ()

    Returns
    RemoteInput The remote input held by this FORMAT_REMOTE_INPUT SliceItem

    getSlice

    Added in API level 28
    public Slice getSlice ()

    Returns
    Slice The slice held by this FORMAT_ACTION or FORMAT_SLICE SliceItem

    getSubType

    Added in API level 28
    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 FORMAT_TEXT items, but only some of them may be Slice#SUBTYPE_MESSAGE.

    Returns
    String

    See also:

    getText

    Added in API level 28
    public CharSequence getText ()

    Returns
    CharSequence The text held by this FORMAT_TEXT SliceItem

    hasHint

    Added in API level 28
    public boolean hasHint (String hint)

    Parameters
    hint String: The hint to check for Value is Slice.HINT_TITLE, Slice.HINT_LIST, Slice.HINT_LIST_ITEM, Slice.HINT_LARGE, Slice.HINT_ACTIONS, Slice.HINT_SELECTED, Slice.HINT_NO_TINT, Slice.HINT_SHORTCUT, android.app.slice.Slice.HINT_TOGGLE, Slice.HINT_HORIZONTAL, Slice.HINT_PARTIAL, Slice.HINT_SEE_MORE, Slice.HINT_KEYWORDS, Slice.HINT_ERROR, Slice.HINT_TTL, Slice.HINT_LAST_UPDATED, or Slice.HINT_PERMISSION_REQUEST

    Returns
    boolean true if this item contains the given hint

    writeToParcel

    Added in API level 28
    public void writeToParcel (Parcel dest, 
                    int flags)

    Flatten this object in to a Parcel.

    Parameters
    dest Parcel: The Parcel in which the object should be written. This value cannot be null.

    flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES