Class ShadowAppWidgetManager


@Implements(android.appwidget.AppWidgetManager.class) public class ShadowAppWidgetManager extends Object
  • Constructor Details

    • ShadowAppWidgetManager

      public ShadowAppWidgetManager()
  • Method Details

    • __constructor__

      @Implementation(maxSdk=19) protected void __constructor__(Context context)
    • __constructor__

      @Implementation(minSdk=21) protected void __constructor__(Context context, service)
    • updateAppWidget

      @Implementation protected void updateAppWidget(int[] appWidgetIds, RemoteViews views)
    • updateAppWidget

      @Implementation protected void updateAppWidget(int appWidgetId, RemoteViews views)
      Simulates updating an AppWidget with a new set of views
      appWidgetId - id of widget
      views - views to update
    • getAppWidgetIds

      @Implementation protected int[] getAppWidgetIds(ComponentName provider)
    • getInstalledProviders

      @Implementation protected List<AppWidgetProviderInfo> getInstalledProviders()
    • getInstalledProvidersForProfile

      @Implementation(minSdk=21) protected List<AppWidgetProviderInfo> getInstalledProvidersForProfile(UserHandle profile)
    • getInstalledProvidersForPackage

      @Implementation(minSdk=26) protected List<AppWidgetProviderInfo> getInstalledProvidersForPackage(String packageName, UserHandle profile)
    • addInstalledProvider

      public void addInstalledProvider(AppWidgetProviderInfo appWidgetProviderInfo)
    • removeInstalledProvider

      public boolean removeInstalledProvider(AppWidgetProviderInfo appWidgetProviderInfo)
    • addInstalledProvidersForProfile

      public void addInstalledProvidersForProfile(UserHandle userHandle, AppWidgetProviderInfo appWidgetProviderInfo)
    • addBoundWidget

      public void addBoundWidget(int appWidgetId, AppWidgetProviderInfo providerInfo)
    • putWidgetInfo

      @Deprecated public void putWidgetInfo(int appWidgetId, AppWidgetProviderInfo expectedWidgetInfo)
    • getAppWidgetInfo

      @Implementation protected AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId)
    • getAppWidgetOptions

      @Implementation protected Bundle getAppWidgetOptions(int appWidgetId)
      Gets the appWidgetOptions Bundle stored in a local cache.
    • updateAppWidgetOptions

      @Implementation protected void updateAppWidgetOptions(int appWidgetId, Bundle options)
      Update the locally cached appWidgetOptions Bundle. Instead of triggering associated AppWidgetProvider.onAppWidgetOptionsChanged through Intent, this implementation calls the method directly.
    • bindAppWidgetId

      @HiddenApi @Implementation public void bindAppWidgetId(int appWidgetId, ComponentName provider)
    • bindAppWidgetId

      @HiddenApi @Implementation protected void bindAppWidgetId(int appWidgetId, ComponentName provider, Bundle options)
    • bindAppWidgetIdIfAllowed

      @Implementation protected boolean bindAppWidgetIdIfAllowed(int appWidgetId, ComponentName provider)
      Create an internal presentation of the widget and cache it locally. This implementation doesn't trigger AppWidgetProvider.onUpdate
    • bindAppWidgetIdIfAllowed

      @Implementation protected boolean bindAppWidgetIdIfAllowed(int appWidgetId, ComponentName provider, Bundle options)
      Create an internal presentation of the widget locally and store the options Bundle with it. This implementation doesn't trigger AppWidgetProvider.onUpdate
    • isRequestPinAppWidgetSupported

      @Implementation(minSdk=26) protected boolean isRequestPinAppWidgetSupported()
      Returns true if setSupportedToRequestPinAppWidget is called with true
    • requestPinAppWidget

      @Implementation(minSdk=26) protected boolean requestPinAppWidget(ComponentName provider, Bundle extras, PendingIntent successCallback)
      This implementation currently uses requestPinAppWidgetSupported to determine if it should bind the app widget provided and execute the successCallback.

      Note: This implementation doesn't trigger AppWidgetProvider.onUpdate.

      provider - The provider for the app widget to bind.
      extras - Returned in the callback along with the ID of the newly bound app widget, sent as AppWidgetManager.EXTRA_APPWIDGET_ID.
      successCallback - Called after binding the app widget, if possible.
      true if the widget was installed, false otherwise.
    • reconstructWidgetViewAsIfPhoneWasRotated

      public void reconstructWidgetViewAsIfPhoneWasRotated(int appWidgetId)
      Triggers a reapplication of the most recent set of actions against the widget, which is what happens when the phone is rotated. Does not attempt to simulate a change in screen geometry.
      appWidgetId - the ID of the widget to be affected
    • createWidget

      public int createWidget(Class<? extends AppWidgetProvider> appWidgetProviderClass, int widgetLayoutId)
      Creates a widget by inflating its layout.
      appWidgetProviderClass - the app widget provider class
      widgetLayoutId - id of the layout to inflate
      the ID of the new widget
    • createWidgets

      public int[] createWidgets(Class<? extends AppWidgetProvider> appWidgetProviderClass, int widgetLayoutId, int howManyToCreate)
      Creates a bunch of widgets by inflating the same layout multiple times.
      appWidgetProviderClass - the app widget provider class
      widgetLayoutId - id of the layout to inflate
      howManyToCreate - number of new widgets to create
      the IDs of the new widgets
    • getViewFor

      public View getViewFor(int widgetId)
      widgetId - id of the desired widget
      the widget associated with widgetId
    • getAppWidgetProviderFor

      public AppWidgetProvider getAppWidgetProviderFor(int widgetId)
      widgetId - id of the widget whose provider is to be returned
      the AppWidgetProvider associated with widgetId
    • setAlwaysRecreateViewsDuringUpdate

      public void setAlwaysRecreateViewsDuringUpdate(boolean alwaysRecreate)
      Enables testing of widget behavior when all of the views are recreated on every update. This is useful for ensuring that your widget will behave correctly even if it is restarted by the OS between events.
      alwaysRecreate - whether or not to always recreate the views
    • getAlwaysRecreateViewsDuringUpdate

      public boolean getAlwaysRecreateViewsDuringUpdate()
      the state of thealwaysRecreateViewsDuringUpdate flag
    • setAllowedToBindAppWidgets

      public void setAllowedToBindAppWidgets(boolean allowed)
    • setRequestPinAppWidgetSupported

      public void setRequestPinAppWidgetSupported(boolean supported)
    • setValidWidgetProviderComponentName

      public void setValidWidgetProviderComponentName(boolean validWidgetProviderComponentName)