tags:

views:

109

answers:

2

Hi,

I'm writing a widget where i first have a configure screen where the user makes a selection. Then I want to pass that data on to the actual widget. This must be really simple but I just can find out how to do it.

A: 

Unsure if this is what you're looking for, but to set the RemoteViews from the configure screen, I use the following:

AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);

RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);

// Set RemoteViews                  
views.setTextViewText(R.id.textview, text);

appWidgetManager.updateAppWidget(mAppWidgetId, views);

// User is finished configuring, effectively closing the configure screen.
Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(RESULT_OK, resultValue);
finish();

More information here: http://developer.android.com/guide/topics/appwidgets/index.html#Configuring

Jeffrey
+1  A: 

I just save the data to Preferences. Widget will read these preferences when it's displayed. Anyway you have to use preferences to persist the selected options.

Fedor
This is how I solved it in the end..
Johan B