belongs to Maven artifact androidx.slice:slice-view:1.0.0-alpha1

SliceMetadata

public class SliceMetadata
extends Object

java.lang.Object
   ↳ androidx.slice.SliceMetadata


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

Summary

Constants

int LOADED_ALL

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

int LOADED_NONE

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

int LOADED_PARTIAL

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

Public methods

static SliceMetadata from(Context context, Slice slice)

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

long getExpiry()

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

int getHeaderType()
PendingIntent getInputRangeAction()

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

long getLastUpdatedTime()
int getLoadingState()
SliceAction getPrimaryAction()
Pair<Integer, Integer> getRange()

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

int getRangeValue()

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

List<SliceItem> getSliceActions()
List<String> getSliceKeywords()
List<SliceAction> getToggles()
boolean hasLargeMode()
boolean isPermissionSlice()

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

Inherited methods

Constants

LOADED_ALL

int LOADED_ALL

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

Constant Value: 2 (0x00000002)

LOADED_NONE

int LOADED_NONE

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

Constant Value: 0 (0x00000000)

LOADED_PARTIAL

int LOADED_PARTIAL

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

Constant Value: 1 (0x00000001)

Public methods

from

SliceMetadata from (Context context, 
                Slice slice)

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

long getExpiry ()

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 ListBuilder.INFINITY if the slice is not time-sensitive.

getHeaderType

int getHeaderType ()

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

getInputRangeAction

PendingIntent getInputRangeAction ()

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

Returns
PendingIntent the PendingIntent for the input range.

getLastUpdatedTime

long getLastUpdatedTime ()

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

getLoadingState

int getLoadingState ()

Returns
int the current loading state for this slice.

getPrimaryAction

SliceAction getPrimaryAction ()

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

getRange

Pair<Integer, Integer> getRange ()

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

Returns
Pair<Integer, Integer> 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

int getRangeValue ()

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

List<SliceItem> getSliceActions ()

Returns
List<SliceItem> the group of actions associated with this slice, if they exist.

getSliceKeywords

List<String> getSliceKeywords ()

Returns
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.

getToggles

List<SliceAction> getToggles ()

Returns
List<SliceAction> the toggles associated with the header of this slice.

hasLargeMode

boolean hasLargeMode ()

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

isPermissionSlice

boolean isPermissionSlice ()

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.