Slice


public final class Slice
extends Object implements Parcelable

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


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 slice is a piece of app content and actions that can be surfaced outside of the app.

They are constructed using Builder in a tree structure that provides the OS some information about how the content should be displayed.

Summary

Nested classes

class Slice.Builder

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. 

Constants

String EXTRA_RANGE_VALUE

Key to retrieve an extra added to an intent when the value of an input range is changed.

String EXTRA_TOGGLE_STATE

Key to retrieve an extra added to an intent when a control is changed.

String HINT_ACTIONS

Hint that this slice contains a number of actions that can be grouped together in a sort of controls area of the UI.

String HINT_ERROR

A hint to indicate that this slice represents an error.

String HINT_HORIZONTAL

Hint that list items within this slice or subslice would appear better if organized horizontally.

String HINT_KEYWORDS

A hint to indicate that the contents of this subslice represent a list of keywords related to the parent slice.

String HINT_LARGE

Hint that this content is important and should be larger when displayed if possible.

String HINT_LAST_UPDATED

Hint indicating an item representing when the content was created or last updated.

String HINT_LIST

Hint that all sub-items/sub-slices within this content should be considered to have HINT_LIST_ITEM.

String HINT_LIST_ITEM

Hint that this item is part of a list and should be formatted as if is part of a list.

String HINT_NO_TINT

Hint to indicate that this content should not be tinted.

String HINT_PARTIAL

Hint to indicate that this slice is incomplete and an update will be sent once loading is complete.

String HINT_PERMISSION_REQUEST

A hint to indicate that this slice represents a permission request for showing slices.

String HINT_SEE_MORE

A hint representing that this item should be used to indicate that there's more content associated with this slice.

String HINT_SELECTED

Hint indicating that this item (and its sub-items) are the current selection.

String HINT_SHORTCUT

Hint to indicate that this content should only be displayed if the slice is presented as a shortcut.

String HINT_SUMMARY

Hint indicating this content should be shown instead of the normal content when the slice is in small format.

String HINT_TITLE

Hint that this content is a title of other content in the slice.

String HINT_TTL

Hint indicating an item representing a time-to-live for the content.

String SUBTYPE_COLOR

Subtype to tag an item as representing a color.

String SUBTYPE_CONTENT_DESCRIPTION

Subtype to tag an item to use as a content description.

String SUBTYPE_LAYOUT_DIRECTION

Subtype to indicate that this item indicates the layout direction for content in the slice.

String SUBTYPE_MAX

Subtype to tag an item as representing the max int value for a SUBTYPE_RANGE.

String SUBTYPE_MESSAGE

Subtype to indicate that this is a message as part of a communication sequence in this slice.

String SUBTYPE_MILLIS

Subtype to tag an item as representing a time in milliseconds since midnight, January 1, 1970 UTC.

String SUBTYPE_PRIORITY

Subtype to tag an item representing priority.

String SUBTYPE_RANGE

Subtype to tag an item as representing a range.

String SUBTYPE_SOURCE

Subtype to tag the source (i.e.

String SUBTYPE_TOGGLE

Subtype to indicate that this content has a toggle action associated with it.

String SUBTYPE_VALUE

Subtype to tag an item as representing the current int value for a SUBTYPE_RANGE.

Inherited constants

Fields

public static final Creator<Slice> CREATOR

Protected constructors

Slice(Parcel in)

Public methods

int describeContents()

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

List<String> getHints()
List<SliceItem> getItems()
SliceSpec getSpec()
Uri getUri()
boolean isCallerNeeded()

Returns whether the caller for this slice matters.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

EXTRA_RANGE_VALUE

Added in API level 28
public static final String EXTRA_RANGE_VALUE

Key to retrieve an extra added to an intent when the value of an input range is changed.

Constant Value: "android.app.slice.extra.RANGE_VALUE"

EXTRA_TOGGLE_STATE

Added in API level 28
public static final String EXTRA_TOGGLE_STATE

Key to retrieve an extra added to an intent when a control is changed.

Constant Value: "android.app.slice.extra.TOGGLE_STATE"

HINT_ACTIONS

Added in API level 28
public static final String HINT_ACTIONS

Hint that this slice contains a number of actions that can be grouped together in a sort of controls area of the UI.

Constant Value: "actions"

HINT_ERROR

Added in API level 28
public static final String HINT_ERROR

A hint to indicate that this slice represents an error.

Constant Value: "error"

HINT_HORIZONTAL

Added in API level 28
public static final String HINT_HORIZONTAL

Hint that list items within this slice or subslice would appear better if organized horizontally.

Constant Value: "horizontal"

HINT_KEYWORDS

Added in API level 28
public static final String HINT_KEYWORDS

A hint to indicate that the contents of this subslice represent a list of keywords related to the parent slice. Expected to be on an item of format SliceItem#FORMAT_SLICE.

Constant Value: "keywords"

HINT_LARGE

Added in API level 28
public static final String HINT_LARGE

Hint that this content is important and should be larger when displayed if possible.

Constant Value: "large"

HINT_LAST_UPDATED

Added in API level 28
public static final String HINT_LAST_UPDATED

Hint indicating an item representing when the content was created or last updated.

Constant Value: "last_updated"

HINT_LIST

Added in API level 28
public static final String HINT_LIST

Hint that all sub-items/sub-slices within this content should be considered to have HINT_LIST_ITEM.

Constant Value: "list"

HINT_LIST_ITEM

Added in API level 28
public static final String HINT_LIST_ITEM

Hint that this item is part of a list and should be formatted as if is part of a list.

Constant Value: "list_item"

HINT_NO_TINT

Added in API level 28
public static final String HINT_NO_TINT

Hint to indicate that this content should not be tinted.

Constant Value: "no_tint"

HINT_PARTIAL

Added in API level 28
public static final String HINT_PARTIAL

Hint to indicate that this slice is incomplete and an update will be sent once loading is complete. Slices which contain HINT_PARTIAL will not be cached by the OS and should not be cached by apps.

Constant Value: "partial"

HINT_PERMISSION_REQUEST

Added in API level 28
public static final String HINT_PERMISSION_REQUEST

A hint to indicate that this slice represents a permission request for showing slices.

Constant Value: "permission_request"

HINT_SEE_MORE

Added in API level 28
public static final String HINT_SEE_MORE

A hint representing that this item should be used to indicate that there's more content associated with this slice.

Constant Value: "see_more"

HINT_SELECTED

Added in API level 28
public static final String HINT_SELECTED

Hint indicating that this item (and its sub-items) are the current selection.

Constant Value: "selected"

HINT_SHORTCUT

Added in API level 28
public static final String HINT_SHORTCUT

Hint to indicate that this content should only be displayed if the slice is presented as a shortcut.

Constant Value: "shortcut"

HINT_SUMMARY

Added in API level 28
public static final String HINT_SUMMARY

Hint indicating this content should be shown instead of the normal content when the slice is in small format.

Constant Value: "summary"

HINT_TITLE

Added in API level 28
public static final String HINT_TITLE

Hint that this content is a title of other content in the slice. This can also indicate that the content should be used in the shortcut representation of the slice (icon, label, action), normally this should be indicated by adding the hint on the action containing that content.

Constant Value: "title"

HINT_TTL

Added in API level 28
public static final String HINT_TTL

Hint indicating an item representing a time-to-live for the content.

Constant Value: "ttl"

SUBTYPE_COLOR

Added in API level 28
public static final String SUBTYPE_COLOR

Subtype to tag an item as representing a color. Expected to be on an item of format SliceItem#FORMAT_INT.

Constant Value: "color"

SUBTYPE_CONTENT_DESCRIPTION

Added in API level 28
public static final String SUBTYPE_CONTENT_DESCRIPTION

Subtype to tag an item to use as a content description. Expected to be on an item of format SliceItem#FORMAT_TEXT.

Constant Value: "content_description"

SUBTYPE_LAYOUT_DIRECTION

Added in API level 28
public static final String SUBTYPE_LAYOUT_DIRECTION

Subtype to indicate that this item indicates the layout direction for content in the slice. Expected to be an item of format SliceItem#FORMAT_INT.

Constant Value: "layout_direction"

SUBTYPE_MAX

Added in API level 28
public static final String SUBTYPE_MAX

Subtype to tag an item as representing the max int value for a SUBTYPE_RANGE. Expected to be on an item of format SliceItem#FORMAT_INT.

Constant Value: "max"

SUBTYPE_MESSAGE

Added in API level 28
public static final String SUBTYPE_MESSAGE

Subtype to indicate that this is a message as part of a communication sequence in this slice. Expected to be on an item of format SliceItem#FORMAT_SLICE.

Constant Value: "message"

SUBTYPE_MILLIS

Added in API level 28
public static final String SUBTYPE_MILLIS

Subtype to tag an item as representing a time in milliseconds since midnight, January 1, 1970 UTC.

Constant Value: "millis"

SUBTYPE_PRIORITY

Added in API level 28
public static final String SUBTYPE_PRIORITY

Subtype to tag an item representing priority. Expected to be on an item of format SliceItem#FORMAT_INT.

Constant Value: "priority"

SUBTYPE_RANGE

Added in API level 28
public static final String SUBTYPE_RANGE

Subtype to tag an item as representing a range. Expected to be on an item of format SliceItem#FORMAT_SLICE containing a SUBTYPE_VALUE and possibly a SUBTYPE_MAX.

Constant Value: "range"

SUBTYPE_SOURCE

Added in API level 28
public static final String SUBTYPE_SOURCE

Subtype to tag the source (i.e. sender) of a SUBTYPE_MESSAGE. Expected to be on an item of format SliceItem#FORMAT_TEXT, SliceItem#FORMAT_IMAGE or an SliceItem#FORMAT_SLICE containing them.

Constant Value: "source"

SUBTYPE_TOGGLE

Added in API level 28
public static final String SUBTYPE_TOGGLE

Subtype to indicate that this content has a toggle action associated with it. To indicate that the toggle is on, use HINT_SELECTED. When the toggle state changes, the intent associated with it will be sent along with an extra EXTRA_TOGGLE_STATE which can be retrieved to see the new state of the toggle.

Constant Value: "toggle"

SUBTYPE_VALUE

Added in API level 28
public static final String SUBTYPE_VALUE

Subtype to tag an item as representing the current int value for a SUBTYPE_RANGE. Expected to be on an item of format SliceItem#FORMAT_INT.

Constant Value: "value"

Fields

CREATOR

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

Protected constructors

Slice

Added in API level 28
protected Slice (Parcel in)

Parameters
in Parcel

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

getHints

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

Returns
List<String> All hints associated with this Slice. Value is HINT_TITLE, HINT_LIST, HINT_LIST_ITEM, HINT_LARGE, HINT_ACTIONS, HINT_SELECTED, HINT_NO_TINT, HINT_SHORTCUT, android.app.slice.Slice.HINT_TOGGLE, HINT_HORIZONTAL, HINT_PARTIAL, HINT_SEE_MORE, HINT_KEYWORDS, HINT_ERROR, HINT_TTL, HINT_LAST_UPDATED, or HINT_PERMISSION_REQUEST

getItems

Added in API level 28
public List<SliceItem> getItems ()

Returns
List<SliceItem> All child SliceItems that this Slice contains.

getSpec

Added in API level 28
public SliceSpec getSpec ()

Returns
SliceSpec The spec for this slice This value may be null.

getUri

Added in API level 28
public Uri getUri ()

Returns
Uri The Uri that this Slice represents.

isCallerNeeded

Added in API level 28
public boolean isCallerNeeded ()

Returns whether the caller for this slice matters.

Returns
boolean

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