SliceViewManager
@RequiresApi(19) abstract class SliceViewManager
kotlin.Any | |
↳ | androidx.slice.SliceViewManager |
Class to handle interactions with Slice
s.
The SliceViewManager manages permissions and pinned state for slices.
Summary
Nested classes | |
---|---|
abstract |
Class that listens to changes in |
Public methods | |
---|---|
abstract Slice? |
Turns a slice Uri into slice content. |
abstract Slice? |
Turns a slice intent into slice content. |
open static SliceViewManager |
getInstance(@NonNull context: Context) Get a |
abstract MutableCollection<Uri!> |
getSliceDescendants(@NonNull uri: Uri) Obtains a list of slices that are descendants of the specified Uri. |
abstract Uri? |
mapIntentToUri(@NonNull intent: Intent) Turns a slice intent into a slice uri. |
abstract Unit |
Ensures that a slice is in a pinned state. |
abstract Unit |
registerSliceCallback(@NonNull uri: Uri, @NonNull callback: SliceViewManager.SliceCallback) Adds a callback to a specific slice uri. |
abstract Unit |
registerSliceCallback(@NonNull uri: Uri, @NonNull executor: Executor, @NonNull callback: SliceViewManager.SliceCallback) Adds a callback to a specific slice uri. |
abstract Unit |
unpinSlice(@NonNull uri: Uri) Remove a pin for a slice. |
abstract Unit |
unregisterSliceCallback(@NonNull uri: Uri, @NonNull callback: SliceViewManager.SliceCallback) Removes a callback for a specific slice uri. |
Public methods
bindSlice
@Nullable abstract fun bindSlice(@NonNull uri: Uri): Slice?
Turns a slice Uri into slice content.
Parameters | |
---|---|
uri |
Uri: The URI to a slice provider |
Return | |
---|---|
Slice? |
The Slice provided by the app or null if none is given. |
See Also
bindSlice
@Nullable abstract fun bindSlice(@NonNull intent: Intent): Slice?
Turns a slice intent into slice content. Is a shortcut to perform the action of both mapIntentToUri(Intent)
and bindSlice(Uri)
at once.
Parameters | |
---|---|
intent |
Intent: The intent associated with a slice. |
Return | |
---|---|
Slice? |
The Slice provided by the app or null if none is given. |
getInstance
@NonNull open static fun getInstance(@NonNull context: Context): SliceViewManager
Get a SliceViewManager
.
getSliceDescendants
@WorkerThread @NonNull abstract fun getSliceDescendants(@NonNull uri: Uri): MutableCollection<Uri!>
Obtains a list of slices that are descendants of the specified Uri.
Not all slice providers will implement this functionality, in which case, an empty collection will be returned.
Parameters | |
---|---|
uri |
Uri: The uri to look for descendants under. |
Return | |
---|---|
MutableCollection<Uri!> |
All slices within the space. |
mapIntentToUri
@Nullable abstract fun mapIntentToUri(@NonNull intent: Intent): Uri?
Turns a slice intent into a slice uri. Expects an explicit intent.
This goes through a several stage resolution process to determine if any slice can represent this intent.
- If the intent contains data that
android.content.ContentResolver#getType
isandroid.app.slice.SliceProvider#SLICE_TYPE
then the data will be returned. - If the intent explicitly points at an activity, and that activity has meta-data for key
android.app.slice.SliceManager#SLICE_METADATA_KEY
, then the Uri specified there will be returned. - Lastly, if the intent with
android.app.slice.SliceManager#CATEGORY_SLICE
added resolves to a provider, then the provider will be asked toSliceProvider#onMapIntentToUri
and that result will be returned. - If no slice is found, then