Android intent intent not specified FLAG_ACTIVITY_SINGLE_TASK?

I just noticed that the FLAG_ACTIVITY_SINGLE_TASK parameter is no longer available in the Android developer documentation:

I'm just trying to do this:

removeCard.setFlags (Intent.FLAG_ACTIVITY_SINGLE_TASK); startActivity (removeCard);

I have already seen such a parameter in the code found on Google, but the Java compiler just tells me that it does not exist.

I can only start the main action with this parameter, but I need to configure the manifest file to complete this:

android: launchMode = "singleTask"

And this does not work for other activities launched when the application starts.

Does anyone know why this option disappears for Intent?

Regards, Franz

+4
source share
3 answers

Well, looking around, I was able to find out that such things as FLAG_ACTIVITY_SINGLE_TASK or FLAG_ACTIVITY_SINGLE_INSTANCE did not exist. This is because you are looking for values โ€‹โ€‹that can only be determined in the application launch mode, which is defined in the manifest. Only the FLAG_ACTIVITY_SINGLE_TOP flag is available as an intent flag. Therefore, if you want to use any of the unidirectional, singleInstance, singleTop or standard launch modes, they must be defined in the manifest:

<activity android:name="com.company.ActivityName" android:launchMode="singleTask"> </activity> 

See the launchMode section in the documentation: http://developer.android.com/guide/topics/manifest/activity-element.html

+3
source

android:launchMode = "singleTask" should work for all actions when used correctly, and you are sure you do not mean FLAG_ACTIVITY_SINGLE_TASK , which is still present and seems to be doing what you want.

public static final int FLAG_ACTIVITY_SINGLE_TOP

Since: API level 1 If set, the action will not be launched if it is already running at the top of the history stack.

+1
source

No, it is not lost. From developer docs ...... Using Intent flags

FLAG_ACTIVITY_NEW_TASK Get started in a new task. If the task is already running for the action that you are currently running, this task is brought to the foreground with the last restored state and the action gets a new intention in onNewIntent (). This leads to the same behavior as the "singleTask" launchMode value, discussed in the previous section.

This means that FLAG_ACTIVITY_NEW_TASK does the same thing as Singletask do.

0
source

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


All Articles