SliceMetadata


@RequiresApi(value = 19)
class SliceMetadata


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

Summary

Constants

const Int

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

const Int

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

const Int

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

Public functions

java-static SliceMetadata
from(context: Context?, slice: Slice)

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

Long

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

Int
Bundle
PendingIntent?

Gets the input range action associated with the header of this slice, if it exists.

Long
Int
SliceAction?
Pair<Int!, Int!>?

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

Int

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

(Mutable)List<SliceAction!>?
(Mutable)List<String!>?
CharSequence?
CharSequence?
CharSequence?
(Mutable)List<SliceAction!>!
Boolean
Boolean

Indicates whether this slice was created using parseSlice or through normal binding.

Boolean

Indicates whether this slice indicates an error, i.e. the normal contents of this slice are unavailable and instead the slice contains a message indicating an error.

Boolean

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

Boolean
Boolean

Sends the intent to adjust the input range value for the header of this slice, if it exists.

Boolean
sendToggleAction(toggleAction: SliceAction!, toggleValue: Boolean)

Sends the intent to adjust the state of the provided toggle action.

Constants

LOADED_ALL

Added in 1.1.0-alpha02
const val LOADED_ALL = 2: Int

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

LOADED_NONE

Added in 1.1.0-alpha02
const val LOADED_NONE = 0: Int

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

LOADED_PARTIAL

Added in 1.1.0-alpha02
const val LOADED_PARTIAL = 1: Int

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

Public functions

from

Added in 1.1.0-alpha02
java-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: Slice

the slice to extract metadata from.

Returns
SliceMetadata

the metadata associated with the provided slice.

getExpiry

Added in 1.1.0-alpha02
fun getExpiry(): Long

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

Returns
Long

the time, measured in milliseconds, between the expiry time of this slice and midnight, January 1, 1970 UTC, or INFINITY if the slice is not time-sensitive.

getHeaderType

Added in 1.1.0-alpha02
fun getHeaderType(): Int
Returns
Int

the type of row that is used for the header of this slice, -1 if unknown.

getHostExtras

Added in 1.1.0-alpha02
fun getHostExtras(): Bundle

getInputRangeAction

Added in 1.1.0-alpha02
fun getInputRangeAction(): PendingIntent?

Gets the input range action associated with the header of this slice, if it exists.

Returns
PendingIntent?

the android.app.PendingIntent for the input range.

getLastUpdatedTime

Added in 1.1.0-alpha02
fun getLastUpdatedTime(): Long
Returns
Long

the time, measured in milliseconds, between when the slice was created or last updated, and midnight, January 1, 1970 UTC.

getLoadingState

Added in 1.1.0-alpha02
fun getLoadingState(): Int
Returns
Int

the current loading state for this slice.

getPrimaryAction

Added in 1.1.0-alpha02
fun getPrimaryAction(): SliceAction?
Returns
SliceAction?

the primary action for this slice, null if none specified.

getRange

Added in 1.1.0-alpha02
fun getRange(): Pair<Int!, Int!>?

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

Returns
Pair<Int!, Int!>?

a pair where the first item is the minimum value of the range and the second item is the maximum value of the range.

getRangeValue

Added in 1.1.0-alpha02
fun getRangeValue(): Int

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

Returns
Int

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

getSliceActions

Added in 1.1.0-alpha02
fun getSliceActions(): (Mutable)List<SliceAction!>?
Returns
(Mutable)List<SliceAction!>?

the group of actions associated with this slice, if they exist.

getSliceKeywords

Added in 1.1.0-alpha02
fun getSliceKeywords(): (Mutable)List<String!>?
Returns
(Mutable)List<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.

getSubtitle

Added in 1.1.0-alpha02
fun getSubtitle(): CharSequence?
Returns
CharSequence?

the subtitle associated with this slice, if it exists.

getSummary

Added in 1.1.0-alpha02
fun getSummary(): CharSequence?
Returns
CharSequence?

the summary associated with this slice, if it exists.

getTitle

Added in 1.1.0-alpha02
fun getTitle(): CharSequence?
Returns
CharSequence?

the title associated with this slice, if it exists.

getToggles

Added in 1.1.0-alpha02
fun getToggles(): (Mutable)List<SliceAction!>!
Returns
(Mutable)List<SliceAction!>!

the toggles associated with the header of this slice.

hasLargeMode

Added in 1.1.0-alpha02
fun hasLargeMode(): Boolean
Returns
Boolean

whether this slice has content to show when presented in MODE_LARGE.

isCachedSlice

Added in 1.1.0-alpha02
fun isCachedSlice(): Boolean

Indicates whether this slice was created using parseSlice or through normal binding.

isErrorSlice

Added in 1.1.0-alpha02
fun isErrorSlice(): Boolean

Indicates whether this slice indicates an error, i.e. the normal contents of this slice are unavailable and instead the slice contains a message indicating an error.

Returns
Boolean

whether this slice represents an error.

isPermissionSlice

Added in 1.1.0-alpha02
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.

Returns
Boolean

whether this slice represents a permission request.

isSelection

Added in 1.1.0-alpha02
fun isSelection(): Boolean
Returns
Boolean

whether this slice is a selection (a drop-down list) slice.

sendInputRangeAction

Added in 1.1.0-alpha02
fun sendInputRangeAction(newValue: Int): Boolean

Sends the intent to adjust the input range value for the header of this slice, if it exists.

Parameters
newValue: Int

the value to set the input range to.

Returns
Boolean

whether there was an action to send.

sendToggleAction

Added in 1.1.0-alpha02
fun sendToggleAction(toggleAction: SliceAction!, toggleValue: Boolean): Boolean

Sends the intent to adjust the state of the provided toggle action.

Parameters
toggleAction: SliceAction!

the toggle action.

toggleValue: Boolean

the new value to set the toggle to.

Returns
Boolean

whether there was an action to send.