Set Intent-flags for PreferenceScreen in xml

My PreferencesActivity view is populated via XML, and in this XML I turned on PreferencesScreen to go to the system synchronization settings. It works fine using the code below.

My problem / question is that when I opened Sync-Preferences, open the home screen and then open my application again, Sync-Settings will open because they are on top of the stack. Is it possible to include the NEW_TASK flag in xml to show on the screen that this is a new task and not related to my application 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> 
+6
source share
1 answer

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> 
On the other hand, the activity of "singleInstance" does not allow any other actions not to participate in its task. This is the only lesson in the task. If it starts another action, this action is assigned to another 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

+1
source

Source: https://habr.com/ru/post/888896/


All Articles