Android Apidemos Sample Resolution (App->activity->reorder) activities

Source: Internet
Author: User

The Reorder activities sample has four related activitives:reorderonlaunch, Reordertwo,reorderthree, Reorderfour. Where Reorderonlaunch is started by the main activity,reorderonlaunch reordertwo, Reordertwo starts reorderthree,reorderthree. In this case the "back stack" of the activity has the following status:

Reorderfour want to start reordertwo again, then use two implementations, one is on the recordfour to start a new reordertwo, this is the default behavior of StartActivity. This is because in Androidmanifest.xml

<activity android:name= ". App. Reordertwo "/>

<activity android:name= ". App. Reorderthree "/>

<activity android:name= ". App. Reorderfour "/>

. App. Recordtwo does not define any flag of this intent. For example, there are flag_activity_new_task,flag_activity_clear_top,flag_activity_single_top, in these cases Android will decide how to start the Recordtwo based on different flag settings, as described in the following example.

In the REORDER activities example, the Reordertwo in the back stack is moved to the top of the stack by setting up Intent.flag_activity_reorder_to_front when the intent is started. If Flag_activity_reorder_to_front is set, the activity specified in back stack is moved to the top of the stack.

Intent Intent = new Intent (reorderfour.this, reordertwo.class);     
Intent.addflags (Intent.flag_activity_reorder_to_front);     
StartActivity (Intent);

The stack is shown in the following illustration:

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.