My app widget needs to be configured when it first added to the home screen. I want to open a configuration view right after the user adds the widget.
AppWidge
In the AppWidgetProvider XML file there is an attribute called android:configure
You can use this to point to an Activity to launch when the app is dropped onto the home screen. ex:
In your chosen configuration activity, the user can make whatever choice they want. You'll need to grab and store the widget's id. In the onCreate
method, get the id like this:
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if (extras != null)
mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
When they've made their selection, use this to send a message back to your home screen widget that it is ready to be displayed:
Intent intent = new Intent();
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(RESULT_OK, intent);
finish();
That'll get what you're after.