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

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)

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