Added in API level 28

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

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

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

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

A hint to indicate that this slice represents an error.

Value: "error"

HINT_HORIZONTAL

Added in API level 28
static val HINT_HORIZONTAL: String

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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
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!>!
Return
MutableList<SliceItem!>! All child SliceItems that this Slice contains.

getSpec

Added in API level 28
fun getSpec(): SliceSpec?
Return
SliceSpec? The spec for this slice This value may be null.

getUri

Added in API level 28
fun getUri(): Uri!
Return
Uri! The Uri that this Slice represents.

isCallerNeeded

Added in API level 28
fun isCallerNeeded(): Boolean

Returns whether the caller for this slice matters.

writeToParcel

Added in API level 28
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
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!>