1.flag_activity_clear_top: For example, the current stack situation is: A B C D. D jumps through intent to B at this point, if the intent adds flag_activity_clear_top tag, the stack becomes: A B. If you do not add this tag, the stack will become: A b C D B. That is, if the flag_activity_clear_top tag is added and the target activity already exists in the stack, the activity on top of that target activity will be ejected from the stack for destruction. This is similar to setting the launch mode of B to Singletask. In short, a jump to an activity that has already existed in the stack will pin the activity on it.
2.flag_activity_new_task: For example, the case of stack 1 now is: A B C. C jumps to D through intent, and this intent adds a flag_activity_new_task tag, and if D this ACTIVITY adds a task affinity to the declaration in Manifest.xml, The system will first look for the same task stack as the D's task affinity, and if it exists, press D into that stack, and if it does not, it will create a new affinity stack of D to press it in. If the task affinity of D is not set by default, it will be pressed into stack 1 and become: a B C D, which is the same as the no-flag_activity_new_task tag effect. Note If you attempt to start an activity from a non-activity non-normal path (see the use case for parameters in the Intent.setflags () method below), such as starting an activity from a service, intent such as to add flag _activity_new_task tags (Editor's note: Activity must exist in the activity stack, not the activity of the way to start activity when there is no activity stack, So a new stack will be loaded into the startup activity). In short, the activity that jumps to is based on the situation and may be pressed into a new stack.
3.flag_activity_no_history: For example, now the stack condition is: A B C. C Jump to D through intent, this intent add flag_activity_no_history flag, then the interface displays the contents of D, but it does not press into the stack. If you press the back key, return to C, the case of the stack is: A B C. If you jump to E in D at this point, the stack becomes: A B C E, at which point the return key will return to C, because D is not pressed into the stack at all. In short, the jump to activity does not press on the stack.
4.flag_activity_single_top: Similar to the singletop of ACTIVITY's launch mode. If a intent adds this flag, and the target activity of this intent is the activity at the top of the stack, then a new instance will not be pressed into the stack. In short, the target activity has been jumped over the top of the stack, not at the top of the stack to create a new activity.
Two. Use cases for parameters in the Intent.setflags () method:
When many people use startactivity, they encounter the following exceptions:
caused By:android.util.AndroidRuntimeException:Calling startactivity () from outside to Activity context requires the Flag_activity_new_task flag. Is this really what do you want?
All know that there is a startactivity method in the context, the activity inherits from the context, overloading the StartActivity method. If you use the StartActivity method of activity, there is no limit, and if you use the StartActivity method of the context, You need to open a new task (editor's note: see StartActivity. 2.), encountering the above exception, is because of the use of the context of the method. The workaround is to add a FLAG, Intent.addflags (Intent.flag_activity_new_task), to the Java code. This allows you to start the activity in a new task.
From: http://blog.csdn.net/berber78/article/details/7278408
The value of the parameter in the Intent.setflags () method means: