Search in sources :

Example 1 with AppWidgetProvider

use of android.appwidget.AppWidgetProvider in project robolectric by robolectric.

the class ShadowActivityTest method shouldNotComplainIfActivityIsDestroyedWhileAnotherActivityHasRegisteredBroadcastReceivers.

@Test
public void shouldNotComplainIfActivityIsDestroyedWhileAnotherActivityHasRegisteredBroadcastReceivers() throws Exception {
    ActivityController<DialogCreatingActivity> controller = Robolectric.buildActivity(DialogCreatingActivity.class);
    activity = controller.get();
    DialogLifeCycleActivity activity2 = Robolectric.setupActivity(DialogLifeCycleActivity.class);
    activity2.registerReceiver(new AppWidgetProvider(), new IntentFilter());
    controller.destroy();
}
Also used : IntentFilter(android.content.IntentFilter) AppWidgetProvider(android.appwidget.AppWidgetProvider) Test(org.junit.Test)

Example 2 with AppWidgetProvider

use of android.appwidget.AppWidgetProvider in project robolectric by robolectric.

the class ShadowAppWidgetManager method createWidgets.

/**
   * Creates a bunch of widgets by inflating the same layout multiple times.
   *
   * @param appWidgetProviderClass the app widget provider class
   * @param widgetLayoutId         id of the layout to inflate
   * @param howManyToCreate        number of new widgets to create
   * @return the IDs of the new widgets
   */
public int[] createWidgets(Class<? extends AppWidgetProvider> appWidgetProviderClass, int widgetLayoutId, int howManyToCreate) {
    AppWidgetProvider appWidgetProvider = ReflectionHelpers.callConstructor(appWidgetProviderClass);
    int[] newWidgetIds = new int[howManyToCreate];
    for (int i = 0; i < howManyToCreate; i++) {
        View widgetView = createWidgetView(widgetLayoutId);
        int myWidgetId = nextWidgetId++;
        widgetInfos.put(myWidgetId, new WidgetInfo(widgetView, widgetLayoutId, appWidgetProvider));
        newWidgetIds[i] = myWidgetId;
    }
    appWidgetProvider.onUpdate(context, realAppWidgetManager, newWidgetIds);
    return newWidgetIds;
}
Also used : AppWidgetProvider(android.appwidget.AppWidgetProvider) View(android.view.View)

Example 3 with AppWidgetProvider

use of android.appwidget.AppWidgetProvider in project robolectric by robolectric.

the class ShadowAppWidgetManager method createWidgetProvider.

private void createWidgetProvider(Class<? extends AppWidgetProvider> appWidgetProviderClass, int... newWidgetIds) {
    AppWidgetProvider appWidgetProvider = ReflectionHelpers.callConstructor(appWidgetProviderClass);
    appWidgetProvider.onUpdate(context, realAppWidgetManager, newWidgetIds);
}
Also used : AppWidgetProvider(android.appwidget.AppWidgetProvider)

Aggregations

AppWidgetProvider (android.appwidget.AppWidgetProvider)3 IntentFilter (android.content.IntentFilter)1 View (android.view.View)1 Test (org.junit.Test)1