Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

AppWidgetProviderWithCallbacks

public class AppWidgetProviderWithCallbacks
extends AppWidgetProvider implements CallbackReceiver<T extends CallbackReceiver>

java.lang.Object
   ↳ android.content.BroadcastReceiver
     ↳ android.appwidget.AppWidgetProvider
       ↳ androidx.remotecallback.AppWidgetProviderWithCallbacks<T extends androidx.remotecallback.CallbackReceiver>


Version of AppWidgetProvider that implements a CallbackReceiver.

Summary

Public constructors

AppWidgetProviderWithCallbacks()

Public methods

T createRemoteCallback(Context context)

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

void onReceive(Context context, Intent intent)
RemoteCallback toRemoteCallback(Class<T> cls, Bundle args, String method)

Inherited methods

Public constructors

AppWidgetProviderWithCallbacks

public AppWidgetProviderWithCallbacks ()

Public methods

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

onReceive

public void onReceive (Context context, 
                Intent intent)

Parameters
context Context

intent Intent

toRemoteCallback

public RemoteCallback toRemoteCallback (Class<T> cls, 
                Bundle args, 
                String method)

Parameters
cls Class

args Bundle

method String

Returns
RemoteCallback