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()
|
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 |
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 ListBuilder.INFINITY if
the slice is not time-sensitive.
|
getHeaderType
public int getHeaderType ()
Returns | |
---|---|
int |
the type of row that is used for the header of this slice, -1 if unknown. |
getInputRangeAction
public PendingIntent getInputRangeAction ()
Gets the input range action associated with the header of this slice, if it exists.
Returns | |
---|---|
PendingIntent |
the PendingIntent for the input range.
|
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:
getPrimaryAction
public SliceAction getPrimaryAction ()
Returns | |
---|---|
SliceAction |
the primary action for this slice, null if none specified. |
getRange
public 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
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 List<SliceAction> getSliceActions ()
Returns | |
---|---|
List<SliceAction> |
the group of actions associated with this slice, if they exist. |
getSliceKeywords
public 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. |
getSubtitle
public CharSequence getSubtitle ()
Returns | |
---|---|
CharSequence |
the subtitle associated with this slice, if it exists. |
getSummary
public CharSequence getSummary ()
Returns | |
---|---|
CharSequence |
the summary associated with this slice, if it exists. |
getTitle
public CharSequence getTitle ()
Returns | |
---|---|
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 SliceView.MODE_LARGE .
|
isCachedSlice
public boolean isCachedSlice ()
Indicates whether this slice was created using SliceUtils.parseSlice(Context, InputStream, String, SliceUtils.SliceActionListener)
or through
normal binding.
Returns | |
---|---|
boolean |
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 | |
---|---|
newValue |
int : the value to set the input range to. |
Returns | |
---|---|
boolean |
whether there was an action to send. |
Throws | |
---|---|
PendingIntent.CanceledException |
sendToggleAction
public boolean sendToggleAction (SliceAction toggleAction, boolean toggleValue)
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. |
Throws | |
---|---|
PendingIntent.CanceledException |