Android 12 Developer Preview is here! Try it out, and give us your feedback!

SliceMetadata

@RequiresApi(19) open class SliceMetadata
kotlin.Any
   ↳ androidx.slice.SliceMetadata

Utility class to parse a Slice and provide access to 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 static SliceMetadata
from(@Nullable context: Context?, @NonNull slice: Slice)

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

open Long

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

open Int

open Bundle

open PendingIntent?

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

open Long

open Int

open SliceAction?

open Pair<Int!, Int!>?

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

open Int

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

open MutableList<SliceAction!>?

open MutableList<String!>?

open CharSequence?

open CharSequence?

open CharSequence?

open MutableList<SliceAction!>!

open Boolean

open Boolean

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

open Boolean

Indicates whether this slice indicates an error, i.

open Boolean

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

open Boolean

open Boolean

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

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

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

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

from

@NonNull open static fun from(
    @Nullable context: Context?,
    @NonNull 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.
Return
SliceMetadata the metadata associated with the provided 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.

getHeaderType

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

getHostExtras

@NonNull open fun getHostExtras(): Bundle

getInputRangeAction

@Nullable open fun getInputRangeAction(): PendingIntent?

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

Return