Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android intent parameter FLAG_ACTIVITY_SINGLE_TASK missing?

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

I am just trying to do this:

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

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

I am only able to start the main activity with this parameter but I have to configure the manifest file to perform this:

android:launchMode = "singleTask"

And this does not work for activities other than main activities launched upon app start.

Does someone know why this parameter disappear for Intent ?

Regards, Franz

like image 923
user255607 Avatar asked Dec 16 '11 15:12

user255607


2 Answers

Ok so after having a look around, I managed to figure out that there is no such things as FLAG_ACTIVITY_SINGLE_TASK or FLAG_ACTIVITY_SINGLE_INSTANCE, nor has there even been. This is because you are looking for values which can only be defined through the application's launch mode which is defined in the manifest. Only FLAG_ACTIVITY_SINGLE_TOP is available as an intent flag. Therefore if you want to make use of any of the singleTask, 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

like image 189
TheIT Avatar answered Oct 15 '22 03:10

TheIT


android:launchMode = "singleTask" should work for all activities when used correctly and are you sure you're not referring the FLAG_ACTIVITY_SINGLE_TASK which is still present and appears to do what you are wanting.

public static final int FLAG_ACTIVITY_SINGLE_TOP

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

like image 1
rogermushroom Avatar answered Oct 15 '22 04:10

rogermushroom