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: