SliceManager
open classSliceManager
kotlin.Any | |
↳ | android.app.slice.SliceManager |
Class to handle interactions with Slice
s.
The SliceManager manages permissions and pinned state for slices.
Summary
Constants | |
---|---|
static String |
Category used to resolve intents that can be rendered as slices. |
static String |
The meta-data key that allows an activity to easily be linked directly to a slice. |
Public methods | |
---|---|
open Slice? |
bindSlice(intent: Intent, supportedSpecs: MutableSet<SliceSpec!>) Turns a slice intent into slice content. |
open Slice? |
bindSlice(uri: Uri, supportedSpecs: MutableSet<SliceSpec!>) Turns a slice Uri into slice content. |
open Int |
checkSlicePermission(uri: Uri, pid: Int, uid: Int) Determine whether a particular process and user ID has been granted permission to access a specific slice URI. |
open MutableList<Uri!> |
Get the list of currently pinned slices for this app. |
open MutableSet<SliceSpec!> |
getPinnedSpecs(uri: Uri!) Get the current set of specs for a pinned slice. |
open MutableCollection<Uri!> |
getSliceDescendants(uri: Uri) Obtains a list of slices that are descendants of the specified Uri. |
open Unit |
grantSlicePermission(toPackage: String, uri: Uri) Grant permission to access a specific slice Uri to another package. |
open Uri? |
mapIntentToUri(intent: Intent) Turns a slice intent into a slice uri. |
open Unit |
pinSlice(uri: Uri, specs: MutableSet<SliceSpec!>) Ensures that a slice is in a pinned state. |
open Unit |
revokeSlicePermission(toPackage: String, uri: Uri) Remove permissions to access a particular content provider Uri that were previously added with |
open Unit |
unpinSlice(uri: Uri) Remove a pin for a slice. |
Constants
CATEGORY_SLICE
static valCATEGORY_SLICE: String
Deprecated: Deprecated in Java.
Category used to resolve intents that can be rendered as slices.
This category should be included on intent filters on providers that extend SliceProvider
.
Value: "android.app.slice.category.SLICE"
SLICE_METADATA_KEY
static valSLICE_METADATA_KEY: String
Deprecated: Deprecated in Java.
The meta-data key that allows an activity to easily be linked directly to a slice.
An activity can be statically linked to a slice uri by including a meta-data item for this key that contains a valid slice uri for the same application declaring the activity.
<activity android:name="com.example.mypkg.MyActivity"> <meta-data android:name="android.metadata.SLICE_URI" android:value="content://com.example.mypkg/main_slice" /> </activity>
Value: "android.metadata.SLICE_URI"
Public methods
bindSlice
open funbindSlice(
intent: Intent,
supportedSpecs: MutableSet<SliceSpec!>
): Slice?
Deprecated: Deprecated in Java.
Turns a slice intent into slice content. Is a shortcut to perform the action of both mapIntentToUri(android.content.Intent)
and bindSlice(android.net.Uri,java.util.Set)
at once.
Parameters | |
---|---|
intent |
Intent: The intent associated with a slice. This value cannot be null . |
supportedSpecs |
MutableSet<SliceSpec!>: List of supported specs. This value cannot be null . |
Return | |
---|---|
Slice? |
The Slice provided by the app or null if none is given. |
bindSlice
open funbindSlice(
uri: Uri,
supportedSpecs: MutableSet<SliceSpec!>
): Slice?
Deprecated: Deprecated in Java.
Turns a slice Uri into slice content.
Parameters | |
---|---|
uri |
Uri: The URI to a slice provider This value cannot be null . |
supportedSpecs |
MutableSet<SliceSpec!>: List of supported specs. This value cannot be null . |
Return | |
---|---|
Slice? |
The Slice provided by the app or null if none is given. |
See Also
checkSlicePermission
open funcheckSlicePermission(
uri: Uri,
pid: Int,
uid: Int
): Int
Deprecated: Deprecated in Java.
Determine whether a particular process and user ID has been granted permission to access a specific slice URI.
Parameters | |
---|---|
uri |
Uri: The uri that is being checked. This value cannot be null . |
pid |
Int: The process ID being checked against. Must be > 0. |
uid |
Int: The user ID being checked against. A uid of 0 is the root user, which will pass every permission check. |
Return | |
---|---|
Int |
PackageManager.PERMISSION_GRANTED if the given pid/uid is allowed to access that uri, or PackageManager.PERMISSION_DENIED if it is not. Value is android.content.pm.PackageManager#PERMISSION_GRANTED , or android.content.pm.PackageManager#PERMISSION_DENIED |
See Also
getPinnedSlices
open fungetPinnedSlices(): MutableList<Uri!>
Deprecated: Deprecated in Java.
Get the list of currently pinned slices for this app.
Return | |
---|---|
MutableList<Uri!> |
This value cannot be null . |
getPinnedSpecs
open fungetPinnedSpecs(uri: Uri!): MutableSet<SliceSpec!>
Deprecated: Deprecated in Java.
Get the current set of specs for a pinned slice.
This is the set of specs supported for a specific pinned slice. It will take into account all clients and returns only specs supported by all.
Return | |
---|---|
MutableSet<SliceSpec!> |
This value cannot be null . |
See Also
getSliceDescendants
open fungetSliceDescendants(uri: Uri): MutableCollection<Uri!>
Deprecated: Deprecated in Java.
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.
This method may take several seconds to complete, so it should only be called from a worker thread.
Parameters | |
---|---|
uri |
Uri: The uri to look for descendants under. This value cannot be null . |
Return | |
---|---|
MutableCollection<Uri!> |
All slices within the space. This value cannot be null . |
grantSlicePermission
open fungrantSlicePermission(
toPackage: String,
uri: Uri
): Unit
Deprecated: Deprecated in Java.
Grant permission to access a specific slice Uri to another package.
Parameters | |
---|---|
toPackage |
String: The package you would like to allow to access the Uri. This value cannot be null . |
uri |
Uri: The Uri you would like to grant access to. This value cannot be null . |
See Also
mapIntentToUri
open funmapIntentToUri(intent: Intent): Uri?
Deprecated: Deprecated in Java.
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
ContentResolver.getType
isSliceProvider.SLICE_TYPE
then the data will be returned. - If the intent explicitly points at an activity, and that activity has meta-data for key
SLICE_METADATA_KEY
, then the Uri specified there will be returned. - Lastly, if the intent with
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
null
is returned.
Parameters | |
---|---|
intent |
Intent: The intent associated with a slice. This value cannot be null . |
Return | |
---|---|
Uri? |
The Slice Uri provided by the app or null if none exists. |
pinSlice
open funpinSlice(
uri: Uri,
specs: MutableSet<SliceSpec!>
): Unit
Deprecated: Deprecated in Java.
Ensures that a slice is in a pinned state.
Pinned state is not persisted across reboots, so apps are expected to re-pin any slices they still care about after a reboot.
This may only be called by apps that are the default launcher for the device or the default voice interaction service. Otherwise will throw SecurityException
.
Parameters | |
---|---|
uri |
Uri: The uri of the slice being pinned. This value cannot be null . |
specs |
MutableSet<SliceSpec!>: The list of supported SliceSpec s of the callback. This value cannot be null . |
revokeSlicePermission
open funrevokeSlicePermission(
toPackage: String,
uri: Uri
): Unit
Deprecated: Deprecated in Java.
Remove permissions to access a particular content provider Uri that were previously added with grantSlicePermission
for a specific target package. The given Uri will match all previously granted Uris that are the same or a sub-path of the given Uri. That is, revoking "content://foo/target" will revoke both "content://foo/target" and "content://foo/target/sub", but not "content://foo". It will not remove any prefix grants that exist at a higher level.
Parameters | |
---|---|
toPackage |
String: The package you would like to allow to access the Uri. This value cannot be null . |
uri |
Uri: The Uri you would like to revoke access to. This value cannot be null . |
See Also
unpinSlice
open fununpinSlice(uri: Uri): Unit
Deprecated: Deprecated in Java.
Remove a pin for a slice.
If the slice has no other pins/callbacks then the slice will be unpinned.
This may only be called by apps that are the default launcher for the device or the default voice interaction service. Otherwise will throw SecurityException
.
Parameters | |
---|---|
uri |
Uri: The uri of the slice being unpinned. This value cannot be null . |