Search code examples
androidandroid-intentandroid-widgetandroid-activityintentfilter

How to add flags to an APPWIDGET_CONFIGURE intent?


I have an activity registered on APPWIDGET_CONFIGURE:

    <activity android:name="com.tahanot.activities.NearbyStops">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
        </intent-filter>
    </activity>

However this activity does not behave as expected. It opens inside of an existing stack, and when I press the Back button, it takes me to other activities instead of closing the task. Ideally, I would like the APPWIDGET_CONFIGURE intent to include FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_MULTIPLE_TASK.

Is it possible to specify flags in AndroidManifest.xml, and if not, what workaround would you suggest?


Solution

  • This is the manifest declaration that I used, following appsroxcom's idea for android:launchMode:

    <activity
        android:name="com.tahanot.activities.NearbyStops"
        android:configChanges="orientation"
        android:label="@string/title_activity_stops_nearby"
        android:launchMode="singleTop"
        android:taskAffinity="com.tahanot.tasks.widgetConfiguration" > 
        <!-- android:launchMode makes sure the Back button doesn't navigate to another NearbyStops activity. 
             android:taskAffinity makes sure the Back button doesn't navigate to some other activity. -->
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
        </intent-filter>
    </activity>