Hi, I'm launching an activity on a buttonclick from AppWidget. The user enters some data on the activity and when user closes the activity, I want to update the data user entered in a TextView on AppWidget. Any idea how to do that? I have successfully launched activity from AppWidget, only problem being updating the AppWidget.
+1
A:
You can use RemoteViews
and the AppWidgetManager
:
AppWidgetManager manager = AppWidgetManager.getInstance(context);
RemoteViews remoteViews = new RemoteViews(
context.getPackageName(), R.layout.widget);
remoteViews.setTextViewText(R.id.textBoxId, "new textbox content");
manager.updateAppWidget(appWidgetId, remoteViews);
Josef
2010-07-30 15:46:21
In which method of my class extending AppWidgetProvider should I add this?
Amit Chintawar
2010-07-31 15:46:34
The snippet will update a `TextView` in your widget. You wrote that you want to update your widget when the user closes an `Activity` so that `Activity`'s `onPause` method would be a good place for example.
Josef
2010-07-31 16:39:45