WEB开发网
开发学院手机开发Android 开发 Android 开发文档 程序基础——Activities and Ta... 阅读

Android 开发文档 程序基础——Activities and Tasks

 2010-06-19 04:19:00 来源:WEB开发网   
核心提示:entire activity stack) can be brought to the foreground or sent to the background. Suppose, for instance, that the current task has four activities in its stack
entire activity stack) can be brought to the foreground or sent to the background. Suppose, for instance, that the current task has four activities in its stack — three under the current activity. The user presses the HOME key, goes to the application launcher, and selects a new application (actually, a new task). The current task goes into the background and the root activity for the new task is displayed. Then, after a short period, the user goes back to the home screen and again selects the previous application (the previous task). That task, with all four activities in the stack, comes forward. When the user presses the BACK key, the screen does not display the activity the user just left (the root activity of the previous task). Rather, the activity on the top of the stack is removed and the previous activity in the same task is displayed.

The behavior just described is the default behavior for activities and tasks. But there are ways to modify almost all aspects of it. The association of activities with tasks, and the behavior of an activity within a task, is controlled by the interaction between flags set in the Intent object that started the activity and attributes set in the activity’s element in the manifest. Both requester and respondent have a say in what happens.

In this regard, the principal Intent flags are:

FLAG_ACTIVITY_NEW_TASK

FLAG_ACTIVITY_CLEAR_TOP

FLAG_ACTIVITY_RESET_TASK_IF_NEEDED

FLAG_ACTIVITY_SINGLE_TOP

The principal attributes are:

taskAffinity

launchMode

allowTaskReparenting

clearTaskOnLaunch

alwaysRetainTaskState

finishOnTaskLaunch

The following sections describe what some of these flags and attributes do, how they interact, and what considerations should govern their use.

  原文:http://buhutuu.cn/google-api/android/android-jichu-activities-tasks/

上一页  1 2 3 

Tags:Android 开发 文档

编辑录入:coldstar [复制链接] [打 印]
赞助商链接