SliceMetadata
@RequiresApi(value = 19)
public class SliceMetadata
Utility class to parse a Slice and provide access to information around its contents.
Summary
Constants |
|
|---|---|
static final int |
LOADED_ALL = 2Indicates this slice has fully loaded and is not waiting for other content. |
static final int |
LOADED_NONE = 0Indicates this slice is empty and waiting for content to be loaded. |
static final int |
LOADED_PARTIAL = 1Indicates this slice has some content but is waiting for other content to be loaded. |
Public methods |
|
|---|---|
static @NonNull SliceMetadata |
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 |
|
@NonNull Bundle |
|
@Nullable PendingIntent |
Gets the input range action associated with the header of this slice, if it exists. |
long |
|
int |
|
@Nullable SliceAction |
|
@Nullable Pair<Integer, Integer> |
getRange()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. |
@Nullable List<SliceAction> |
|
@Nullable List<String> |
|
@Nullable CharSequence |
|
@Nullable CharSequence |
|
@Nullable CharSequence |
getTitle() |
List<SliceAction> |
|
boolean |
|
boolean |
Indicates whether this slice was created using |
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 |
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. |
Constants
LOADED_ALL
public static final int LOADED_ALL = 2
Indicates this slice has fully loaded and is not waiting for other content.
LOADED_NONE
public static final int LOADED_NONE = 0
Indicates this slice is empty and waiting for content to be loaded.
LOADED_PARTIAL
public static final int LOADED_PARTIAL = 1
Indicates this slice has some content but is waiting for other content to be loaded.
Public methods
from
public static @NonNull SliceMetadata from(@Nullable Context context, @NonNull Slice slice)
Create a SliceMetadata object to provide access to some information around the slice and its contents.
| Parameters | |
|---|---|
@Nullable Context context |
the context to use for the slice. |
@NonNull Slice slice |
the slice to extract metadata from. |
| Returns | |
|---|---|
@NonNull 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 |
getHeaderType
public int getHeaderType()
| Returns | |
|---|---|
int |
the type of row that is used for the header of this slice, -1 if unknown. |
getInputRangeAction
public @Nullable PendingIntent getInputRangeAction()
Gets the input range action associated with the header of this slice, if it exists.
| Returns | |
|---|---|
@Nullable PendingIntent |
the |
getLastUpdatedTime
public 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
public int getLoadingState()
| Returns | |
|---|---|
int |
the current loading state for this slice. |
| See also | |
|---|---|
LOADED_NONE |
|
LOADED_PARTIAL |
|
LOADED_ALL |
getPrimaryAction
public @Nullable SliceAction getPrimaryAction()
| Returns | |
|---|---|
@Nullable SliceAction |
the primary action for this slice, null if none specified. |
getRange
public @Nullable Pair<Integer, Integer> getRange()
Gets the range information associated with a progress bar or input range associated with this slice, if it exists.
getRangeValue
public 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
public @Nullable List<SliceAction> getSliceActions()
| Returns | |
|---|---|
@Nullable List<SliceAction> |
the group of actions associated with this slice, if they exist. |
getSubtitle
public @Nullable CharSequence getSubtitle()
| Returns | |
|---|---|
@Nullable CharSequence |
the subtitle associated with this slice, if it exists. |
getSummary
public @Nullable CharSequence getSummary()
| Returns | |
|---|---|
@Nullable CharSequence |
the summary associated with this slice, if it exists. |
getTitle
public @Nullable CharSequence getTitle()
| Returns | |
|---|---|
@Nullable CharSequence |
the title associated with this slice, if it exists. |
getToggles
public List<SliceAction> getToggles()
| Returns | |
|---|---|
List<SliceAction> |
the toggles associated with the header of this slice. |
hasLargeMode
public boolean hasLargeMode()
| Returns | |
|---|---|
boolean |
whether this slice has content to show when presented in |
isCachedSlice
public boolean isCachedSlice()
Indicates whether this slice was created using parseSlice or through normal binding.
isErrorSlice
public boolean isErrorSlice()
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
public 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. |
isSelection
public boolean isSelection()
| Returns | |
|---|---|
boolean |
whether this slice is a selection (a drop-down list) slice. |
sendInputRangeAction
public boolean sendInputRangeAction(int newValue)
Sends the intent to adjust the input range value for the header of this slice, if it exists.
| Parameters | |
|---|---|
int newValue |
the value to set the input range to. |
| Returns | |
|---|---|
boolean |
whether there was an action to send. |
sendToggleAction
public boolean sendToggleAction(SliceAction toggleAction, boolean toggleValue)
Sends the intent to adjust the state of the provided toggle action.
| Parameters | |
|---|---|
SliceAction toggleAction |
the toggle action. |
boolean toggleValue |
the new value to set the toggle to. |
| Returns | |
|---|---|
boolean |
whether there was an action to send. |