ContentProviderWithCallbacks


public abstract class ContentProviderWithCallbacks<T extends ContentProviderWithCallbacks> extends ContentProvider implements CallbackReceiver

Version of ContentProvider that can be used as a CallbackReceiver. Be sure to call the super of call when unhandled to ensure callbacks are triggered.

Parameters
<T extends ContentProviderWithCallbacks>

Should be specified as the root class (e.g. class X extends ContentProviderWithCallbacks\)

Summary

Public constructors

Public methods

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

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

Inherited Constants

From android.content.ComponentCallbacks2
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

Inherited methods

From android.content.ContentProvider

Public constructors

ContentProviderWithCallbacks

Added in 1.0.0-alpha03
Deprecated in 1.0.0-alpha03
public ContentProviderWithCallbacks()

Public methods

attachInfo

public void attachInfo(Context context, ProviderInfo info)

call

public @Nullable Bundlecall(@NonNull String method, @Nullable String arg, @Nullable Bundle extras)

createRemoteCallback

public @NonNull T createRemoteCallback(@NonNull 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;
    }