I have a Widget which has a ConfigActivity. If I place my Widget on the homescreen the first time, everything is working as expected:
- User Places Widget -> WidgetConfig is launched
- User Configures Widget
- User Clicks accept
- Homescreen with Widget is shown and updated by a Service.
There is an icon on the Widget that allows the user to come back to the Configuration. The Bug appears, if the User launched the App, presses the HomeButton, and clicks after that on the WidgetConfigIcon:
- User Clicks WidgetConfigIcon -> WidgetConfig is launched
- User Configures and clicks accept
- APP is shown instead of HomeScreen
- User presses BackButton
- HomeScreen is shown.
it doesn’t appear if the user starts the app, and clicks the BackButton instead of the HomeButton. I want the exact same behavior for the ConfigIcon, as it is on the firt place on the Homescreen. I post relevant implementation
WidgetService:
Intent activityIntent = new Intent(this, WidgetConfig.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//tried many Flags with no result
activityIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mWidgetData.getWidgetId());
PendingIntent configPendingIntent = PendingIntent.getActivity(this, mWidgetData.getWidgetId(), activityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mRemoteViews.setOnClickPendingIntent(R.id.widget_controls, configPendingIntent);
ManifestEntry:
<activity
android:name="namespace.WidgetConfig"
android:theme="@android:style/Theme.Light.NoTitleBar">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
</intent-filter>
</activity>
I will post any other code if requested.
What can I do to prevent the App coming up after the User finished the configuration?
I get it to work myself. I added the IntentFlag
Intent.FLAG_ACTIVITY_NEW_TASKand also added a customandroid:taskAffinity:"some.custom.widgetConfig.task.ns"inside my Android-Manifest and it is working.