Class ShadowAppWidgetManager

    • Constructor Detail

      • ShadowAppWidgetManager

        public ShadowAppWidgetManager()
    • Method Detail

      • __constructor__

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

        @Implementation(minSdk=21)
        protected void __constructor__​(Context context,
                                       com.android.internal.appwidget.IAppWidgetService 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
        Parameters:
        appWidgetId - id of widget
        views - views to update
      • getAppWidgetIds

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

        public void addInstalledProvider​(AppWidgetProviderInfo appWidgetProviderInfo)
      • getAppWidgetInfo

        @Implementation
        protected AppWidgetProviderInfo getAppWidgetInfo​(int appWidgetId)
      • bindAppWidgetId

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

        @Implementation
        protected boolean bindAppWidgetIdIfAllowed​(int appWidgetId,
                                                   ComponentName provider)
      • 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.
        Parameters:
        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.
        Parameters:
        appWidgetProviderClass - the app widget provider class
        widgetLayoutId - id of the layout to inflate
        Returns:
        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.
        Parameters:
        appWidgetProviderClass - the app widget provider class
        widgetLayoutId - id of the layout to inflate
        howManyToCreate - number of new widgets to create
        Returns:
        the IDs of the new widgets
      • getViewFor

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

        public AppWidgetProvider getAppWidgetProviderFor​(int widgetId)
        Parameters:
        widgetId - id of the widget whose provider is to be returned
        Returns:
        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.
        Parameters:
        alwaysRecreate - whether or not to always recreate the views
      • getAlwaysRecreateViewsDuringUpdate

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

        public void setAllowedToBindAppWidgets​(boolean allowed)
      • setValidWidgetProviderComponentName

        public void setValidWidgetProviderComponentName​(boolean validWidgetProviderComponentName)