Save activity status
As described in the previous section, the system saves its status when the activity is stopped by default. as a result, when a user navigating to the previous activity, the user interface is displayed the same as when the user leaves. then, you can-and should-Use your activity callback method in advance to maintain its status, because the activity may be destroyed and re-created. when the system stops your activitie (for example, when a new activity is started or the task is moved to the background), the system may completely destroy the activity to release the memory. when this happens, the activity status is lost. if this happens, the system still knows that the activity occupies a position in the back stack, but when the activity is obtained to the foreground, the system must re-create it (rather than just restore it ). to avoid losing users' work, you should implementonSaveInstanceState()
c
To save the status in advance.
For more information about saving activitystate, see http://blog.csdn.net/nkmnkm/article/details/7101178.
Manage tasks
Android manages tasks and backs up stacks, as described in the previous article-by placing all the activities that are successively started in the same task and in the same stack that is later-first-out-works well in most applications and you don't need to worry about your how the activity is related to the task or how it exists in the back stack. however, you may decide to break this normal behavior. you may want to start a new task (instead of placing it in the current stack) when the activity of your application is started; or, when you start an activity, you want to bring an instance that has been running to the foreground (instead of creating a new instance at the top of the back stack); or, when you want the user to leave the task, your rollback stack clears all the activities except the root activity.
You can do these things, or even more, by setting the <activity> attribute in manifest and passing it to the flag of the intent of startactivity.
At this point, the most important <activity> attributes you can set are:
Taskaffinity
Launchmode
Allowtaskreparenting
Cleartaskonlaunch
Alwaysretaintaskstate
Finishontasklaunch
The most important intent flag that can be used:
Flag_activity_new_task
Flag_activity_clear_top
Flag_activity_single_top
Note:Most applications should not changeActivityAnd default task behavior. If you are sure you must change the default behavior, you must be careful and ensure that the test is complete.ActivityThe availability of navigation at startup and backend ensures that navigation behaviors that conflict with user habits are tested.