1. Demo description and demonstrationThis demo mainly demonstrates the use of flag_activity_reorder_to_front.
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.
The stack is shown in: