Explanation of flag parameters in Android development
Source: Internet
Author: User
<span id="Label3"></p><p><p><strong>explanation of flag parameters in Android development:</strong><br>The intent object plays an important role in Android development and has built-in rich constants for transmitting data,<br>The following article will describe some of the flag parameters related to the task, the understanding of the parameters are from the Android API and my experience in the actual project, if there is a description of the inappropriate, but also ask you to Enlighten.</p></p><p><p><strong>1.flag_activity_brought_to_front:</strong> not set in program code, the system helps you set the Singletask mode in Launchmode.</p></p><p><p><strong>2.flag_activity_clear_top:</strong> cleans up all activity on the activity that you want to start. The activity is at the top of the Stack.<br>For example, there is a activity:a,b,c,d in an activity stack. If D calls StartActivity () starts with b, then both C and D will end.</p></p><p><strong><strong>3.flag_activity_new_task:</strong></strong>The activity will be the beginning of a new Task.<br>Here is a detailed explanation of Flag_activity_new_task Flag. Set this status principle as Follows:<br><strong><strong>(1).</strong></strong>The affinity of the activity in the same application is taskaffinity the Same. This means that the activity is in the same stack.<br><strong><strong>(2).</strong></strong>When the flag is set, the task stack is first searched for the presence and activation of the activity with the same Affinity.<br>If so, move the stack to the foreground and keep the state of the stack intact, that is, the activity in the stack is in the same order.<br>If not, a new stack is created to hold the activity that was Started.<br>For example:<br>A.<strong><strong>prerequisites:</strong></strong>Activity A and Activity B are in the same application.<br> <strong><strong>operation:</strong></strong>Activity A starts the secluded task stack (stack state: A), starts activity B in activity a, and the flag of intent that initiates activity B is set to<br><strong><strong>Flag_activity_new_task</strong></strong>, activity B is pressed into the stack where activity A is located (stack state:-A).<br>Reason:<strong><strong>by default, all activity in an app has the same affinity (taskaffinity). that is, in the same stack. </strong></strong> <br><strong><strong>B. premises:</strong></strong>Activity A in an app named "taskone app", activity C and Activity D are in an app named "tasktwo app."<br><strong><strong>Action 1:</strong></strong>Click the TaskOne app icon in launcher, Activity A launches the secluded task stack, named Taska (taska stack state: A),<br>Starting activity C in activity a, the flag of intent with activity C set to flag_activity_new_task,android system will open secluded a new TASK for activity c, named TASKB (TASKB Stack status: c), Long Press the home key, select Taska,activity a back to the foreground, start Activity C again (two cases 1. Start from the desktop; 2. Start with activity a, as in both cases), and taskb back to the front desk, Activity c shows that, for the user, the task that contains Flag_activity_new_task's intent start ACTIVITY is running, and instead of creating a new task for the activity, the original task is returned to the foreground display.</p><p><p><strong>4.flag_activity_single_top:</strong> If the activity is at the top of the activity stack, a new instance is no longer created. otherwise, a new instance is Created. The activation mode equivalent to activity launch mode is Singletop.</p></p><p><p><strong>5.flag_activity_exclude_from_recents:</strong> If set, the new activity will not be saved in the list of recently launched Activity.</p></p> <p><p>Explanation of flag parameters in Android development</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service