Because i have more than one widget provider class:
- I have a separate set of code to update the widgets for each provider. I couldnt find a way to have one set of code update all widgets for all widget providers (but i continue to believe it is possible).
Im using a service class to update the widgets, so i am using "ComponentName" to get the widgetIds for each widget provider class.
My solution is this, repeated for each widget provider class:
// update all 2x2 widget instances
ComponentName thisWidget2x2 = new ComponentName(getBaseContext(), WidgetProvider2x2.class);
int[] allWidgetIds2x2 = localAppWidgetManager.getAppWidgetIds(thisWidget2x2);
for (int widgetId : allWidgetIds2x2) {
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.widget_layout_2x2);
remoteViews.setImageViewResource(R.id.imageviewA_B, timePhraseA_B);
remoteViews.setOnClickPendingIntent(R.id.topLayout, openAwcPi);
localAppWidgetManager.updateAppWidget(widgetId, remoteViews);
}
This is repeated for each widget provider