6

My PreferencesActivity's view is populated through XML and in that XML I included a PreferencesScreen to navigate to the system's sync-preferences. It works fine using the code below.

My problem/question is, that when I opened the Sync-Preferences, open the home-screen and then open my App again, the Sync-Settings are opened, because they lie on top of the stack. Is there a possibility to include the NEW_TASK-flag in the xml to tell the screen that it's a new task and not associated with my App's stack?

<PreferenceScreen
        android:title="@string/preferences_activity_syncaccounts_title"
        android:summary="@string/preferences_activity_syncaccounts_summary"
        android:dialogTitle="@string/preferences_activity_syncaccounts_title">
        <intent
            android:action="android.settings.SYNC_SETTINGS"/>
    </PreferenceScreen>
Anthony Grist
  • 38,173
  • 8
  • 62
  • 76
dst
  • 1,770
  • 13
  • 26

1 Answers1

1

You can set android:launchMode="singleInstance". In your code example this would be:

    <PreferenceScreen
        android:title="@string/preferences_activity_syncaccounts_title"
        android:summary="@string/preferences_activity_syncaccounts_summary"
        android:dialogTitle="@string/preferences_activity_syncaccounts_title">
    <intent
        android:action="android.settings.SYNC_SETTINGS"
        android:launchMode="singleInstance" />
    </PreferenceScreen>

A "singleInstance" activity, on the other hand, permits no other activities to be part of its task. It's the only activity in the task. If it starts another activity, that activity is assigned to a different task — as if FLAG_ACTIVITY_NEW_TASK was in the intent.

You can read more here: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

mcia
  • 151
  • 4