[Apidemos for Android samples video series] app-activity-reorder activities

Source: Internet
Author: User

1. Demo description and demonstration

This demo mainly demonstrates the use of flag_activity_reorder_to_front.

As follows:

2. Video description

3. Demo Analysis

The Reorder activities example has four related activitives: reorderonlaunch, reordertwo, reorderthree, and reorderfour. Reorderonlaunch is the main activity, reorderonlaunch starts reordertwo, reordertwo starts reorderthree, and reorderthree starts reorderfour. In this case, the "back stack" Status of the activity is as follows:


Reorderfour wants to start reordertwo again. At this time, two implementation methods are used. One is to start a new reordertwo on recordfour, which 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 for this intent.For exampleFlag_activity_new_task, flag_activity_clear_top, flag_activity_single_top. In these cases, Android determines how to start recordtwo Based on Different flag settings. The following example describes how to start recordtwo.

In the reorder activities example, the reordertwo in "Back stack" is moved to the top of the stack by setting intent. flag_activity_reorder_to_front when 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.

  1. Intent intent = new intent (reorderfour. This, reordertwo. Class );
  2. Intent. addflags (intent. flag_activity_reorder_to_front );
  3. Startactivity (intent );


The stack is shown in:

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.