SliceMetadata

public class SliceMetadata
extends Object

java.lang.Object
   ↳ androidx.slice.SliceMetadata


Utility class to parse a Slice and provide access to 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()
Bundle getHostExtras()
PendingIntent getInputRangeAction()

Gets the input range action associated with the header of 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<SliceAction> getSliceActions()
List<String> getSliceKeywords()
CharSequence getSubtitle()
CharSequence getSummary()
CharSequence getTitle()
List<SliceAction> getToggles()
boolean hasLargeMode()
boolean isCachedSlice()

Indicates whether this slice was created using SliceUtils.parseSlice(Context, InputStream, String, SliceUtils.SliceActionListener) or through normal binding.

boolean isErrorSlice()

Indicates whether this slice indicates an error, i.e.

boolean isPermissionSlice()

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

boolean isSelection()
boolean sendInputRangeAction(int newValue)

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

boolean sendToggleAction(SliceAction toggleAction, boolean toggleValue)

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

Inherited methods

Constants

LOADED_ALL

public static final int LOADED_ALL

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

Constant Value: 2 (0x00000002)

LOADED_NONE

public static final int LOADED_NONE

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

Constant Value: 0 (0x00000000)

LOADED_PARTIAL

public static final 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

public static 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

public 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