SliceMetadata

open class SliceMetadata
kotlin.Any
   ↳ androidx.slice.SliceMetadata

Utility class to parse a Slice and provide access to some information around its contents.

Summary

Constants
static Int

Indicates this slice has fully loaded and is not waiting for other content.

static Int

Indicates this slice is empty and waiting for content to be loaded.

static Int

Indicates this slice has some content but is waiting for other content to be loaded.

Public methods
open MutableList<SliceAction!>!

open MutableList<String!>?

open Long

open Boolean

open Int

open Boolean

To present a slice from another app, the app must grant uri permissions for the slice.

open Pair?

Gets the range information associated with a progress bar or input range associated with this slice, if it exists.

open SliceAction?

open Int

Gets the current value for a progress bar or input range associated with this slice, if it exists, -1 if unknown.

open Long

A slice contains an expiry to indicate when the content in the slice might no longer be valid.

open Int

open MutableList<SliceAction!>?

open PendingIntent?

Gets the input range action associated for this slice, if it exists.

open static SliceMetadata!
from(context: Context, slice: Slice)

Create a SliceMetadata object to provide access to some information around the slice and its contents.

Constants

LOADED_ALL

static val LOADED_ALL: Int

Indicates this slice has fully loaded and is not waiting for other content.

Value: 2

LOADED_NONE

static val LOADED_NONE: Int

Indicates this slice is empty and waiting for content to be loaded.

Value: 0

LOADED_PARTIAL

static val LOADED_PARTIAL: Int

Indicates this slice has some content but is waiting for other content to be loaded.

Value: 1

Public methods

getToggles

open fun getToggles(): MutableList<SliceAction!>!
Return
MutableList<SliceAction!>!: the toggles associated with the header of this slice.

getSliceKeywords

open fun getSliceKeywords(): MutableList<String!>?
Return
MutableList<String!>?: the list of keywords associated with the provided slice, null if no keywords were specified or an empty list if the slice was specified to have no keywords.

getLastUpdatedTime

open fun getLastUpdatedTime(): Long
Return
Long: the time, measured in milliseconds, between when the slice was created or last updated, and midnight, January 1, 1970 UTC.

hasLargeMode

open fun hasLargeMode(): Boolean
Return
Boolean: whether this slice has content to show when presented in SliceView#MODE_LARGE.

getHeaderType

open fun getHeaderType(): Int
Return
Int: the type of row that is used for the header of this slice, -1 if unknown.

isPermissionSlice

open fun isPermissionSlice(): Boolean

To present a slice from another app, the app must grant uri permissions for the slice. If these permissions have not been granted and the app slice is requested then a permission request slice will be returned instead, allowing the user to grant permission. This method can be used to identify if a slice is a permission request.

Return
Boolean: whether this slice represents a permission request.

getRange

open fun getRange(): Pair?

Gets the range information associated with a progress bar or input range associated with this slice, if it exists.

Return
Pair?: a pair where the first item is the minimum value of the range and the second item is the maximum value of the range.

getPrimaryAction

open fun getPrimaryAction(): SliceAction?
Return
SliceAction?: the primary action for this slice, null if none specified.

getRangeValue

open fun getRangeValue(): Int

Gets the current value for a progress bar or input range associated with this slice, if it exists, -1 if unknown.

Return
Int: the current value of a progress bar or input range associated with this slice.

getExpiry

open fun getExpiry(): Long

A slice contains an expiry to indicate when the content in the slice might no longer be valid.

Return
Long: the time, measured in milliseconds, between the expiry time of this slice and midnight, January 1, 1970 UTC, or androidx.slice.builders.ListBuilder#INFINITY if the slice is not time-sensitive.

getLoadingState

open fun getLoadingState(): Int
Return
Int: the current loading state for this slice.

getSliceActions

open fun getSliceActions(): MutableList<SliceAction!>?
Return
MutableList<SliceAction!>?: the group of actions associated with this slice, if they exist.

getInputRangeAction

open fun getInputRangeAction(): PendingIntent?

Gets the input range action associated for this slice, if it exists.

Return
PendingIntent?: the android.app.PendingIntent for the input range.

from

open static fun from(context: Context, slice: Slice): SliceMetadata!

Create a SliceMetadata object to provide access to some information around the slice and its contents.

Parameters
context Context: the context to use for the slice.
slice Context: the slice to extract metadata from.
Return
SliceMetadata!: the metadata associated with the provided slice.