Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

SliceProviderWithCallbacks

public abstract class SliceProviderWithCallbacks
extends SliceProvider implements CallbackReceiver<T extends SliceProviderWithCallbacks>

java.lang.Object
   ↳ android.content.ContentProvider
     ↳ androidx.slice.SliceProvider
       ↳ androidx.slice.SliceProviderWithCallbacks<T extends androidx.slice.SliceProviderWithCallbacks>


Version of SliceProvider that can be used as a CallbackReceiver. Be sure to call the super of call(String, String, Bundle) when unhandled to ensure callbacks are triggered.

Summary

Inherited constants

Public constructors

SliceProviderWithCallbacks()

Public methods

void attachInfo(Context context, ProviderInfo info)
Bundle call(String method, String arg, Bundle extras)
T createRemoteCallback(Context context)

Creates a RemoteCallback that will call the method with method specified with the arguments specified when triggered.

Inherited methods

Public constructors

SliceProviderWithCallbacks

public SliceProviderWithCallbacks ()

Public methods

attachInfo

public void attachInfo (Context context, 
                ProviderInfo info)

Parameters
context Context

info ProviderInfo

call

public Bundle call (String method, 
                String arg, 
                Bundle extras)

Parameters
method String

arg String

extras Bundle

Returns
Bundle

createRemoteCallback

public T createRemoteCallback (Context context)

Creates a RemoteCallback that will call the method with method specified with the arguments specified when triggered. Only methods tagged with RemoteCallable can be used here. This method returns a stub implementation of the class calling it to record the arguments/method being used. This should only be used in a chain of 2 calls, starting with createRemoteCallback(), then followed up with a call to any method tagged with RemoteCallable.

     createRemoteCallback().callMyMethod("My arguments", 43, 2.4)
              .toPendingIntent(context);
 
     \@RemoteCallable
     public RemoteCallback callMyMethod(String argStr, int argInt, double argDouble) {
         ...
         return RemoteCallback.LOCAL;
     }
 

Parameters
context Context

Returns
T