Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.


abstract class SliceProvider : ContentProvider, CompatWrapped
   ↳ android.content.ContentProvider
   ↳ androidx.slice.SliceProvider

A SliceProvider allows an app to provide Slices to the Android OS. A slice is a piece of app content and actions that can be displayed outside of the app in Android system surfaces or within another app. Slices are identified by a Uri and a SliceProvider allows your app to provide a slice based on a uri.

The primary method to implement in SliceProvider is onBindSlice(Uri) which is called whenever something wants to display a slice from your app. An app can have multiple slices all served from the same slice provider, the Uri passed to onBindSlice will identify the specific slice being requested.

public MySliceProvider extends SliceProvider {
       public Slice onBindSlice(Uri sliceUri) {
           String path = sliceUri.getPath();
           switch (path) {
               case "/weather":
                   return createWeatherSlice(sliceUri);
               case "/traffic":
                   return createTrafficSlice(sliceUri);
           return null;

Slices are constructed with

Slices are not currently live content. They are bound once and shown to the user. If the content in the slice changes due to user interaction or an update in the data being displayed, then ContentResolver#notifyChange(Uri, ContentObserver) should be used to notify the system to request the latest slice from the app.

The provider needs to be declared in the manifest to provide the authority for the app. The authority for most slices is expected to match the package of the application.

      android:authorities="" />

Slices can also be identified by an intent. To link an intent with a slice, the slice provider must have an IntentFilter matching the slice intent. When a slice is being requested via an intent, onMapIntentToUri(Intent) will be called and is expected to return an appropriate Uri representing the slice.

          <action android:name="android.intent.action.MY_SLICE_INTENT" />
          <category android:name="" />


Public constructors
<init>(@NonNull vararg autoGrantPermissions: String!)

A version of constructing a SliceProvider that allows autogranting slice permissions to apps that hold specific platform permissions.

Public methods
open Unit
attachInfo(@Nullable context: Context?, @Nullable info: ProviderInfo?)

bulkInsert(@NonNull uri: Uri, @NonNull values: Array<ContentValues!>)

open Bundle?
call(@NonNull method: String, @Nullable arg: String?, @Nullable extras: Bundle?)

Handles the call to SliceProvider.

canonicalize(@NonNull url: Uri)

delete(@NonNull uri: Uri, @Nullable selection: String?, @Nullable selectionArgs: Array<String!>?)

open MutableList<Uri!>

Returns a list of slice URIs that are currently pinned.

getType(@NonNull uri: Uri)

insert(@NonNull uri: Uri, @Nullable values: ContentValues?)

abstract Slice?
onBindSlice(@NonNull sliceUri: Uri)

Implemented to create a slice.


open PendingIntent?
onCreatePermissionRequest(@NonNull sliceUri: Uri, @NonNull callingPackage: String)

Called when an app requests a slice it does not have write permission to the uri for.

abstract Boolean

Implement this to initialize your slice provider on startup.

open MutableCollection<Uri!>
onGetSliceDescendants(@NonNull uri: Uri)

Obtains a list of slices that are descendants of the specified Uri.

open Uri
onMapIntentToUri(@NonNull intent: Intent)

This method must be overridden if an IntentFilter is specified on the SliceProvider.

open Unit
onSlicePinned(@NonNull sliceUri: Uri)

Called to inform an app that a slice has been pinned.

open Unit
onSliceUnpinned(@NonNull sliceUri: Uri)

Called to inform an app that a slices is no longer pinned.

query(@NonNull uri: Uri, @Nullable projection: Array<String!>?, @Nullable selection: String?, @Nullable selectionArgs: Array<String!>?, @Nullable sortOrder: String?)

query(@NonNull uri: Uri, @Nullable projection: Array<String!>?, @Nullable queryArgs: Bundle?, @Nullable cancellationSignal: CancellationSignal?)

query(@NonNull uri: Uri, @Nullable projection: Array<String!>?, @Nullable selection: String?, @Nullable selectionArgs: Array<String!>?, @Nullable sortOrder: String?, @Nullable cancellationSignal: CancellationSignal?)

update(@NonNull uri: Uri, @Nullable values: ContentValues?, @Nullable selection: String?, @Nullable selectionArgs: Array<String!>?)

Public constructors


SliceProvider(@NonNull vararg autoGrantPermissions: String!)

A version of constructing a SliceProvider that allows autogranting slice permissions to apps that hold specific platform permissions.

When an app tries to bind a slice from a provider that it does not have access to, the provider will check if the caller holds permissions to any of the autoGrantPermissions specified, if they do they will be granted persisted uri access to all slices of this provider.

autoGrantPermissions String!: List of permissions that holders are auto-granted access to slices.



Public methods


open fun attachInfo(
    @Nullable context: Context?,
    @Nullable info: ProviderInfo?
): Unit


fun bulkInsert(
    @NonNull uri: Uri,
    @NonNull values: Array<ContentValues!>
): Int


@Nullable open fun call(
    @NonNull method: String,
    @Nullable arg: String?,
    @Nullable extras: Bundle?
): Bundle?

Handles the call to SliceProvider.

This function is unsupported for sdk < 19. For sdk 28 and above the call is handled by


@Nullable @RequiresApi(19) fun canonicalize(@NonNull url: Uri): Uri?


fun delete(
    @NonNull uri: Uri,
    @Nullable selection: String?,
    @Nullable selectionArgs: Array<String!>?
): Int


@NonNull @RequiresApi(19) open fun getPinnedSlices(): MutableList<