Clearing the back stack
If the user leaves a task for a long time, the system clears the task of all activities except the root activity. When the user returns to the task again, only the root activity is restored. The system behaves this way, because, after an extended amount of time, users likely have abandoned what they were doing before and are returning to the task to begin something new.
There are some activity attributes that you can use to modify this behavior:
alwaysRetainTaskState
If this attribute is set to "true" in the root activity of a task, the default behavior just described does not happen. The task retains all activities in its stack even after a long period.
clearTaskOnLaunch
If this attribute is set to "true" in the root activity of a task, the stack is cleared down to the root activity whenever the user leaves the task and returns to it. In other words, it's the opposite of alwaysRetainTaskState. The user always returns to the task in its initial state, even after a leaving the task for only a moment.
finishOnTaskLaunch
This attribute is like clearTaskOnLaunch, but it operates on a single activity, not an entire task. It can also cause any activity to go away, including the root activity. When it's set to "true", the activity remains part of the task only for the current session. If the user leaves and then returns to the task, it is no longer present.
clearTaskOnLaunch: 如果root activity设置了true,那么
通过startActivity再次调用此activity就会重新执行onCreate。
通过桌面laucher调用,则会把task里其他activities清除掉,执行onResume。
finishOnTaskLaunch:如果activity设置了true,那么
通过startActivity再次调用此activity就会重新执行onCreate。
posted on 2011-06-17 18:55
汪杰 阅读(1342)
评论(0) 编辑 收藏 引用 所属分类:
Java