Added in API level 28
Deprecated in API level 35

Slice


class Slice : Parcelable
kotlin.Any
   ↳ android.app.slice.Slice

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

A Builder used to construct Slices

Constants
static String

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

static String

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

static String

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

static String

A hint to indicate that this slice represents an error.

static String

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

static String

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

static String

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

static String

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

static String

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

static String

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

static String

Hint to indicate that this content should not be tinted.

static String

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

static String

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

static String

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

static String

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

static String

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

static String

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

static String

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

static String

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

static String

Subtype to tag an item as representing a color.

static String

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

static String

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

static String

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

static String

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

static String

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

static String

Subtype to tag an item representing priority.

static String

Subtype to tag an item as representing a range.

static String

Subtype to tag the source (i.e. sender) of a

static String

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

static String

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

Inherited constants
Protected constructors
Slice(in: Parcel!)

Public methods
Int

MutableList<String!>!

MutableList<SliceItem!>!

SliceSpec?

Uri!

Boolean

Returns whether the caller for this slice matters.

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<Slice!>

Constants

EXTRA_RANGE_VALUE

Added in API level 28
static val EXTRA_RANGE_VALUE: String

Deprecated: Deprecated in Java.

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

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

EXTRA_TOGGLE_STATE

Added in API level 28
static val EXTRA_TOGGLE_STATE: String

Deprecated: Deprecated in Java.

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

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

HINT_ACTIONS

Added in API level 28
static val HINT_ACTIONS: String

Deprecated: Deprecated in Java.

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

Value: "actions"

HINT_ERROR

Added in API level 28
static val HINT_ERROR: String

Deprecated: Deprecated in Java.

A hint to indicate that this slice represents an error.

Value: "error"

HINT_HORIZONTAL

Added in API level 28
static val HINT_HORIZONTAL: String

Deprecated: Deprecated in Java.

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

Value: "horizontal"

HINT_KEYWORDS

Added in API level 28
static val HINT_KEYWORDS: String

Deprecated: Deprecated in Java.

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.

Value: "keywords"

HINT_LARGE

Added in API level 28
static val HINT_LARGE: String

Deprecated: Deprecated in Java.

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

Value: "large"

HINT_LAST_UPDATED

Added in API level 28
static val HINT_LAST_UPDATED: String

Deprecated: Deprecated in Java.

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

Value: "last_updated"

HINT_LIST

Added in API level 28
static val HINT_LIST: String

Deprecated: Deprecated in Java.

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

Value: "list"

HINT_LIST_ITEM

Added in API level 28
static val HINT_LIST_ITEM: String

Deprecated: Deprecated in Java.

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

Value: "list_item"

HINT_NO_TINT

Added in API level 28
static val HINT_NO_TINT: String

Deprecated: Deprecated in Java.

Hint to indicate that this content should not be tinted.

Value: "no_tint"

HINT_PARTIAL

Added in API level 28
static val HINT_PARTIAL: String

Deprecated: Deprecated in Java.

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.

Value: "partial"

HINT_PERMISSION_REQUEST

Added in API level 28
static val HINT_PERMISSION_REQUEST: String

Deprecated: Deprecated in Java.

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

Value: "permission_request"

HINT_SEE_MORE

Added in API level 28
static val HINT_SEE_MORE: String

Deprecated: Deprecated in Java.

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

Value: "see_more"

HINT_SELECTED

Added in API level 28
static val HINT_SELECTED: String

Deprecated: Deprecated in Java.

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

Value: "selected"

HINT_SHORTCUT

Added in API level 28
static val HINT_SHORTCUT: String

Deprecated: Deprecated in Java.

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

Value: "shortcut"

HINT_SUMMARY

Added in API level 28
static val HINT_SUMMARY: String

Deprecated: Deprecated in Java.

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

Value: "summary"

HINT_TITLE

Added in API level 28
static val HINT_TITLE: String

Deprecated: Deprecated in Java.

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.

Value: "title"

HINT_TTL

Added in API level 28
static val HINT_TTL: String

Deprecated: Deprecated in Java.

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

Value: "ttl"

SUBTYPE_COLOR

Added in API level 28
static val SUBTYPE_COLOR: String

Deprecated: Deprecated in Java.

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

Value: "color"

SUBTYPE_CONTENT_DESCRIPTION

Added in API level 28
static val SUBTYPE_CONTENT_DESCRIPTION: String

Deprecated: Deprecated in Java.

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

Value: "content_description"

SUBTYPE_LAYOUT_DIRECTION

Added in API level 28
static val SUBTYPE_LAYOUT_DIRECTION: String

Deprecated: Deprecated in Java.

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.

Value: "layout_direction"

SUBTYPE_MAX

Added in API level 28
static val SUBTYPE_MAX: String

Deprecated: Deprecated in Java.

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.

Value: "max"

SUBTYPE_MESSAGE

Added in API level 28
static val SUBTYPE_MESSAGE: String

Deprecated: Deprecated in Java.

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.

Value: "message"

SUBTYPE_MILLIS

Added in API level 28
static val SUBTYPE_MILLIS: String

Deprecated: Deprecated in Java.

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

Value: "millis"

SUBTYPE_PRIORITY

Added in API level 28
static val SUBTYPE_PRIORITY: String

Deprecated: Deprecated in Java.

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

Value: "priority"

SUBTYPE_RANGE

Added in API level 28
static val SUBTYPE_RANGE: String

Deprecated: Deprecated in Java.

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.

Value: "range"

SUBTYPE_SOURCE

Added in API level 28
static val SUBTYPE_SOURCE: String

Deprecated: Deprecated in Java.

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.

Value: "source"

SUBTYPE_TOGGLE

Added in API level 28
static val SUBTYPE_TOGGLE: String

Deprecated: Deprecated in Java.

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.

Value: "toggle"

SUBTYPE_VALUE

Added in API level 28
static val SUBTYPE_VALUE: String

Deprecated: Deprecated in Java.

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.

Value: "value"

Protected constructors

Slice

Added in API level 28
protected Slice(in: Parcel!)

Public methods

describeContents

Added in API level 28
fun describeContents(): Int

Deprecated: Deprecated in Java.

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getItems

Added in API level 28
fun getItems(): MutableList<SliceItem!>!

Deprecated: Deprecated in Java.

Return
MutableList<SliceItem!>! All child SliceItems that this Slice contains.

getSpec

Added in API level 28
fun getSpec(): SliceSpec?

Deprecated: Deprecated in Java.

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

getUri

Added in API level 28
fun getUri(): Uri!

Deprecated: Deprecated in Java.

Return
Uri! The Uri that this Slice represents.

isCallerNeeded

Added in API level 28
fun isCallerNeeded(): Boolean

Deprecated: Deprecated in Java.

Returns whether the caller for this slice matters.

writeToParcel

Added in API level 28
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

Deprecated: Deprecated in Java.

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_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 28
static val CREATOR: Parcelable.Creator<Slice!>

Deprecated: Deprecated in Java.