SliceMetadata
@RequiresApi(value = 19)
class SliceMetadata
Utility class to parse a Slice and provide access to information around its contents.
Summary
Constants |
|
|---|---|
const Int |
LOADED_ALL = 2Indicates this slice has fully loaded and is not waiting for other content. |
const Int |
LOADED_NONE = 0Indicates this slice is empty and waiting for content to be loaded. |
const Int |
LOADED_PARTIAL = 1Indicates this slice has some content but is waiting for other content to be loaded. |
Public functions |
|
|---|---|
java-static 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 |
|
Bundle |
|
PendingIntent? |
Gets the input range action associated with the header of this slice, if it exists. |
Long |
|
Int |
|
SliceAction? |
|
Pair<Int!, Int!>? |
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. |
(Mutable)List<SliceAction!>? |
|
(Mutable)List<String!>? |
|
CharSequence? |
|
CharSequence? |
|
CharSequence? |
getTitle() |
(Mutable)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(newValue: Int)Sends the intent to adjust the input range value for the header of this slice, if it exists. |
Boolean |
sendToggleAction(toggleAction: SliceAction!, toggleValue: Boolean)Sends the intent to adjust the state of the provided toggle action. |
Constants
LOADED_ALL
const val LOADED_ALL = 2: Int
Indicates this slice has fully loaded and is not waiting for other content.
LOADED_NONE
const val LOADED_NONE = 0: Int
Indicates this slice is empty and waiting for content to be loaded.
LOADED_PARTIAL
const val LOADED_PARTIAL = 1: Int
Indicates this slice has some content but is waiting for other content to be loaded.
Public functions
from
java-static fun from(context: Context?, 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. |
| Returns | |
|---|---|
SliceMetadata |
the metadata associated with the provided slice. |
getExpiry
fun getExpiry(): Long
A slice contains an expiry to indicate when the content in the slice might no longer be valid.
getHeaderType
fun getHeaderType(): Int
| Returns | |
|---|---|
Int |
the type of row that is used for the header of this slice, -1 if unknown. |
getInputRangeAction
fun getInputRangeAction(): PendingIntent?
Gets the input range action associated with the header of this slice, if it exists.
| Returns | |
|---|---|
PendingIntent? |
the |
getLastUpdatedTime
fun getLastUpdatedTime(): Long
| Returns | |
|---|---|
Long |
the time, measured in milliseconds, between when the slice was created or last updated, and midnight, January 1, 1970 UTC. |
getLoadingState
fun getLoadingState(): Int
| Returns | |
|---|---|
Int |
the current loading state for this slice. |
| See also | |
|---|---|
LOADED_NONE |
|
LOADED_PARTIAL |
|
LOADED_ALL |
getPrimaryAction
fun getPrimaryAction(): SliceAction?
| Returns | |
|---|---|
SliceAction? |
the primary action for this slice, null if none specified. |
getRange
fun getRange(): Pair<Int!, Int!>?
Gets the range information associated with a progress bar or input range associated with this slice, if it exists.
getRangeValue
fun getRangeValue(): Int
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
fun getSliceActions(): (Mutable)List<SliceAction!>?
| Returns | |
|---|---|
(Mutable)List<SliceAction!>? |
the group of actions associated with this slice, if they exist. |
getSubtitle
fun getSubtitle(): CharSequence?
| Returns | |
|---|---|
CharSequence? |
the subtitle associated with this slice, if it exists. |
getSummary
fun getSummary(): CharSequence?
| Returns | |
|---|---|
CharSequence? |
the summary associated with this slice, if it exists. |
getTitle
fun getTitle(): CharSequence?
| Returns | |
|---|---|
CharSequence? |
the title associated with this slice, if it exists. |
getToggles
fun getToggles(): (Mutable)List<SliceAction!>!
| Returns | |
|---|---|
(Mutable)List<SliceAction!>! |
the toggles associated with the header of this slice. |
hasLargeMode
fun hasLargeMode(): Boolean
| Returns | |
|---|---|
Boolean |
whether this slice has content to show when presented in |
isCachedSlice
fun isCachedSlice(): Boolean
Indicates whether this slice was created using parseSlice or through normal binding.
isErrorSlice
fun isErrorSlice(): 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.
| Returns | |
|---|---|
Boolean |
whether this slice represents an error. |
isPermissionSlice
fun isPermissionSlice(): Boolean
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
fun isSelection(): Boolean
| Returns | |
|---|---|
Boolean |
whether this slice is a selection (a drop-down list) slice. |
sendInputRangeAction
fun sendInputRangeAction(newValue: Int): Boolean
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. |
sendToggleAction
fun sendToggleAction(toggleAction: SliceAction!, toggleValue: Boolean): Boolean
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. |