views:

88

answers:

2

I have a widget with an associated PreferenceActivity/PreferenceScreen. I would like to update my widget whenever the user is finished setting the preferences. I am using onBackPressed in my PreferenceActivity, which is being called, but the widget's onUpdate is not being called. Can anyone shed any light on this please?

public void onBackPressed() { if (CONFIGURE_ACTION.equals(getIntent().getAction())) { Intent intent=getIntent(); intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); Bundle extras=intent.getExtras();

if (extras!=null) { int id=extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); AppWidgetManager mgr=AppWidgetManager.getInstance(this); RemoteViews views=new RemoteViews(getPackageName(), R.layout.widget);

mgr.updateAppWidget(id, views);

Intent result=new Intent();

result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
setResult(RESULT_OK, result);
sendBroadcast(new Intent(this, WidgetProvider.class));

} } super.onBackPressed(); }

A: 

same issue for me

Premier
A: 

I solved this problem eventually. Take a look at this article... Using PreferencesActivity from a widget?

CellsReinvent