Package org.robolectric.shadows
Class ShadowAppWidgetManager
- java.lang.Object
-
- org.robolectric.shadows.ShadowAppWidgetManager
-
@Implements(android.appwidget.AppWidgetManager.class) public class ShadowAppWidgetManager extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ShadowAppWidgetManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void__constructor__(android.content.Context context)protected void__constructor__(android.content.Context context, com.android.internal.appwidget.IAppWidgetService service)voidaddBoundWidget(int appWidgetId, android.appwidget.AppWidgetProviderInfo providerInfo)voidaddInstalledProvider(android.appwidget.AppWidgetProviderInfo appWidgetProviderInfo)voidbindAppWidgetId(int appWidgetId, android.content.ComponentName provider)protected booleanbindAppWidgetIdIfAllowed(int appWidgetId, android.content.ComponentName provider)intcreateWidget(java.lang.Class<? extends android.appwidget.AppWidgetProvider> appWidgetProviderClass, int widgetLayoutId)Creates a widget by inflating its layout.int[]createWidgets(java.lang.Class<? extends android.appwidget.AppWidgetProvider> appWidgetProviderClass, int widgetLayoutId, int howManyToCreate)Creates a bunch of widgets by inflating the same layout multiple times.booleangetAlwaysRecreateViewsDuringUpdate()protected int[]getAppWidgetIds(android.content.ComponentName provider)protected android.appwidget.AppWidgetProviderInfogetAppWidgetInfo(int appWidgetId)android.appwidget.AppWidgetProvidergetAppWidgetProviderFor(int widgetId)protected java.util.List<android.appwidget.AppWidgetProviderInfo>getInstalledProviders()android.view.ViewgetViewFor(int widgetId)voidputWidgetInfo(int appWidgetId, android.appwidget.AppWidgetProviderInfo expectedWidgetInfo)Deprecated.voidreconstructWidgetViewAsIfPhoneWasRotated(int appWidgetId)Triggers a reapplication of the most recent set of actions against the widget, which is what happens when the phone is rotated.voidsetAllowedToBindAppWidgets(boolean allowed)voidsetAlwaysRecreateViewsDuringUpdate(boolean alwaysRecreate)Enables testing of widget behavior when all of the views are recreated on every update.voidsetValidWidgetProviderComponentName(boolean validWidgetProviderComponentName)protected voidupdateAppWidget(int[] appWidgetIds, android.widget.RemoteViews views)protected voidupdateAppWidget(int appWidgetId, android.widget.RemoteViews views)Simulates updating anAppWidgetwith a new set of views
-
-
-
Method Detail
-
__constructor__
@Implementation(maxSdk=19) protected void __constructor__(android.content.Context context)
-
__constructor__
@Implementation(minSdk=21) protected void __constructor__(android.content.Context context, com.android.internal.appwidget.IAppWidgetService service)
-
updateAppWidget
@Implementation protected void updateAppWidget(int[] appWidgetIds, android.widget.RemoteViews views)
-
updateAppWidget
@Implementation protected void updateAppWidget(int appWidgetId, android.widget.RemoteViews views)Simulates updating anAppWidgetwith a new set of views- Parameters:
appWidgetId- id of widgetviews- views to update
-
getAppWidgetIds
@Implementation protected int[] getAppWidgetIds(android.content.ComponentName provider)
-
getInstalledProviders
@Implementation protected java.util.List<android.appwidget.AppWidgetProviderInfo> getInstalledProviders()
-
addInstalledProvider
public void addInstalledProvider(android.appwidget.AppWidgetProviderInfo appWidgetProviderInfo)
-
addBoundWidget
public void addBoundWidget(int appWidgetId, android.appwidget.AppWidgetProviderInfo providerInfo)
-
putWidgetInfo
@Deprecated public void putWidgetInfo(int appWidgetId, android.appwidget.AppWidgetProviderInfo expectedWidgetInfo)Deprecated.
-
getAppWidgetInfo
@Implementation protected android.appwidget.AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId)
-
bindAppWidgetId
@HiddenApi @Implementation public void bindAppWidgetId(int appWidgetId, android.content.ComponentName provider)
-
bindAppWidgetIdIfAllowed
@Implementation protected boolean bindAppWidgetIdIfAllowed(int appWidgetId, android.content.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(java.lang.Class<? extends android.appwidget.AppWidgetProvider> appWidgetProviderClass, int widgetLayoutId)Creates a widget by inflating its layout.- Parameters:
appWidgetProviderClass- the app widget provider classwidgetLayoutId- id of the layout to inflate- Returns:
- the ID of the new widget
-
createWidgets
public int[] createWidgets(java.lang.Class<? extends android.appwidget.AppWidgetProvider> appWidgetProviderClass, int widgetLayoutId, int howManyToCreate)Creates a bunch of widgets by inflating the same layout multiple times.- Parameters:
appWidgetProviderClass- the app widget provider classwidgetLayoutId- id of the layout to inflatehowManyToCreate- number of new widgets to create- Returns:
- the IDs of the new widgets
-
getViewFor
public android.view.View getViewFor(int widgetId)
- Parameters:
widgetId- id of the desired widget- Returns:
- the widget associated with
widgetId
-
getAppWidgetProviderFor
public android.appwidget.AppWidgetProvider getAppWidgetProviderFor(int widgetId)
- Parameters:
widgetId- id of the widget whose provider is to be returned- Returns:
- the
AppWidgetProviderassociated withwidgetId
-
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 the
alwaysRecreateViewsDuringUpdateflag
-
setAllowedToBindAppWidgets
public void setAllowedToBindAppWidgets(boolean allowed)
-
setValidWidgetProviderComponentName
public void setValidWidgetProviderComponentName(boolean validWidgetProviderComponentName)
-
-