欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

android task與back stack 開發文檔翻譯 - 1

系統 1905 0

由于本人英文能力實在有限,不足之初敬請諒解

本博客只要沒有注明“轉”,那么均為原創,轉貼請注明鏈接

android task與back stack 開發文檔翻譯 - 1

android task與back stack 開發文檔翻譯 - 2

android task與back stack 開發文檔翻譯 - 3

?

Task和Back Stack

?

An application usually contains multiple activities.?

Each activity should be designed around a specific kind of action the user can perform and can start other activities.?

For example, an email application might have one activity to show a list of new email.?

When the user selects an email, a new activity opens to view that email.

一個應用通常包含多個activity

每個activity都應該被設計成圍繞著一種用戶可執行并且能打開其他activity明確的action

例如:一個郵件應用也許有一個activity用來顯示新郵件列表

當用戶選中一封郵件時,一個新activity被打開,用來查看這封郵件。

?

?

An activity can even start activities that exist in other applications on the device.?

For example, if your application wants to send an email, you can define an intent to perform a "send" action and include some data, such as an email address and a message.?

An activity from another application that declares itself to handle this kind of intent then opens.?

In this case, the intent is to send an email, so an email application's "compose" activity starts (if multiple activities support the same intent, then the system lets the user select which one to use).?

When the email is sent, your activity resumes and it seems as if the email activity was part of your application.?

Even though the activities may be from different applications, Android maintains this seamless user experience by keeping both activities in the same task.

一個activity甚至可以打開設備中存在于其他應用的activity

例如:如果你的應用想發送一封郵件,你可以定義一個intent用來執行一個發送的action并且包含一些數據,比如郵件地址和信息

其他應用中,聲明它自己可以處理這樣的intent的activity會打開。

這個例子中,intent用來發送郵件,所以一個郵件程序的"compose" activity會啟動(如果多個activity都支持這個intent,那么系統會讓用戶選擇使用哪一個)

當郵件發送完畢,你的activity會resume并且郵件的activity看上去好像你的應用的一部分

雖然activity可能來自不同的應用,Android通過保持兩個應用的activity在同一個task中來保持這種無縫的用戶體驗。

?

?

A task is a collection of activities that users interact with when performing a certain job.?

The activities are arranged in a stack (the "back stack"), in the order in which each activity is opened.

一個task是用戶執行一個任務時,與用戶交互的activity的一個集合

這些activity按著被打開的順序被整理到一個stack中(back stack)

?

?

The device Home screen is the starting place for most tasks.?

When the user touches an icon in the application launcher (or a shortcut on the Home screen), that application's task comes to the foreground.?

If no task exists for the application (the application has not been used recently), then a new task is created and the "main" activity for that application opens as the root activity in the stack.

設備的Home頁面是大多數task的起始位置。

當用戶觸摸一個在launcher應用中的圖標(或者Home頁面中的快捷方式)時,應用的task就會來到前臺。

如果這個應用還沒有task(這個應用最近沒有被使用過),那么一個新的task會被建立并且應用的“主”activity作為stack的根activity被打開。

?

?

When the current activity starts another, the new activity is pushed on the top of the stack and takes focus.?

The previous activity remains in the stack, but is stopped.?

When an activity stops, the system retains the current state of its user interface.?

When the user presses the Back button, the current activity is popped from the top of the stack (the activity is destroyed) and the previous activity resumes (the previous state of its UI is restored).?

Activities in the stack are never rearranged, only pushed and popped from the stack—pushed onto the stack when started by the current activity and popped off when the user leaves it using the Back button.?

As such, the back stack operates as a "last in, first out" object structure.?

Figure 1 visualizes this behavior with a timeline showing the progress between activities along with the current back stack at each point in time.

當當前activity打開另一個activity時,新的activity會被推入stack的頂部并且獲得焦點

前一個activity仍然在stack中,但是處于stopped狀態

當一個activity處于stop狀態時,系統會保持它當前的UI狀態

當用戶按back鍵時,當前的activity從stack頂部彈出(activity會被銷毀)并且上一個activity變成resume狀態(上一個UI狀態被恢復)

stack中的activity絕不會重新排列,在stack中只有壓入和彈出 —— 當被當前的activity啟動時壓入stack,當用戶使用back鍵離開它時彈出。

就其本身而言,back stack操作是像“后進先出”的對象結構一樣

下圖通過程序在多個activity之間連同當前的back stack適時地在每一個點的時間線展示了這種行為。

android task與back stack 開發文檔翻譯 - 1

Figure 1. A representation of how each new activity in a task adds an item to the back stack.?

When the user presses the Back button, the current activity is destroyed and the previous activity resumes.

上圖為task中每一個新activity如何向添加一個條目到back stack的展示。

當用戶按下back鍵時,當前的activity被銷毀并且恢復上一個activity。

?

?

If the user continues to press Back, then each activity in the stack is popped off to reveal the previous one, until the user returns to the Home screen (or to whichever activity was running when the task began).?

When all activities are removed from the stack, the task no longer exists.

如果用戶繼續按back鍵,那么每一個在stack中的activity都會彈出暴露出上一個activity,直到用戶返回到Home(或者退回到task開始時運行的activity)

當所有activity都被從stack中移除之后,task也就不復存在了。

?

?

android task與back stack 開發文檔翻譯 - 1

A task is a cohesive unit that can move to the "background" when users begin a new task or go to the Home screen, via the Home button.?

While in the background, all the activities in the task are stopped, but the back stack for the task remains intact—the task has simply lost focus while another task takes place, as shown in figure 2.?

A task can then return to the "foreground" so users can pick up where they left off.?

Suppose, for example, that the current task (Task A) has three activities in its stack—two under the current activity.?

The user presses the Home button, then starts a new application from the application launcher.?

When the Home screen appears, Task A goes into the background.?

When the new application starts, the system starts a task for that application (Task B) with its own stack of activities.?

After interacting with that application, the user returns Home again and selects the application that originally started Task A.?

Now, Task A comes to the foreground—all three activities in its stack are intact and the activity at the top of the stack resumes.?

At this point, the user can also switch back to Task B by going Home and selecting the application icon that started that task (or by touching and holding the Home button to reveal recent tasks and selecting one).?

This is an example of multitasking on Android.

task是一個緊密結合的單元,當用戶打開一個新的task或者瀏覽Home主屏時,task可以移動到“后臺”

當在后臺時,task中所有的activity都是stopped狀態,但是task的back stack保持完整,當另一個task占據位置時之前的task只是簡單的失去焦點,如上圖所示。

task可以返回到前臺,所以用戶可以回到他們離開的地方。

假設:例如當前的task(task A)在他的stack中有3個activity,其中兩個在當前activity下面。

用戶按下Home鍵,然后從launcher應用啟動一個新的應用。

當home頁面出現的時候,task進入后臺。

當新的應用開啟時,系統為這個新應用自己的activity的stack開啟一個task(Task B)

與新應用交互完成之后,用戶返回Home然后選擇啟動task A的原始應用。

現在,Task A來到前臺,stack中的3個activity原封不動沒有改變,stack最頂部的activity重新開始。

這時候,用戶可以通過去Home選擇啟動Task B的應用圖標轉換回到Task B(或者通過長按Home鍵顯示出最近的task,然后選擇)

這是一個android上面的多任務的例子。

?

?

Note: Multiple tasks can be held in the background at once.?

However, if the user is running many background tasks at the same time, the system might begin destroying background activities in order to recover memory, causing the activity states to be lost.?

See the following section about Activity state.

注意:多task可以同時進入后臺。

然而,如果用戶同時運行了很多task在后臺,系統也許為了恢復內存而開始銷毀后臺的activity,導致activty的狀態丟失


android task與back stack 開發文檔翻譯 - 1

Because the activities in the back stack are never rearranged, if your application allows users to start a particular activity from more than one activity, a new instance of that activity is created and pushed onto the stack (rather than bringing any previous instance of the activity to the top).?

As such, one activity in your application might be instantiated multiple times (even from different tasks), as shown in figure 3.?

As such, if the user navigates backward using the Back button, each instance of the activity is revealed in the order they were opened (each with their own UI state).?

However, you can modify this behavior if you do not want an activity to be instantiated more than once.?

How to do so is discussed in the later section about Managing Tasks.

因為back stack中activity絕不會重新排列,如果你的應用允許用戶從多于一個的activity打開一個特別的activity,一個新的這個activity實例被建立并且壓入stack中(而不是把這個activity之前的任何實例帶到stack頂部)

就其本身而言,你應用中的一個activity也許會被實例化多次(甚至從不同的task中),如上圖所示

同樣,如果用戶用back鍵導航回退,每一個activity實例會按著他們被打開的順序依次顯露出來(帶著他們自己的UI狀態)

不管怎樣,如果你不希望一個activity被實例化多次你可以修改這種行為。

如果修改將在下面的管理task章節討論

?

?

?

To summarize the default behavior for activities and tasks:

activity和task的默認行為摘要

?

When Activity A starts Activity B, Activity A is stopped, but the system retains its state (such as scroll position and text entered into forms).?

If the user presses the Back button while in Activity B, Activity A resumes with its state restored.

When the user leaves a task by pressing the Home button, the current activity is stopped and its task goes into the background.?

The system retains the state of every activity in the task.?

If the user later resumes the task by selecting the launcher icon that began the task, the task comes to the foreground and resumes the activity at the top of the stack.

If the user presses the Back button, the current activity is popped from the stack and destroyed.?

The previous activity in the stack is resumed.?

When an activity is destroyed, the system does not retain the activity's state.

Activities can be instantiated multiple times, even from other tasks.

當Activity A開啟Activity B時,Activity A進入stop狀態,但是系統保持Activity自己的狀態(比如滾動的位置和文本輸入的形式)

在Activity B中如果用戶按下back鍵,Activity A會和它自己的狀態一起恢復。

當用戶通過按Home鍵離開一個task時,當前的activity處于stop并且它的task進入后臺

系統保持task中每一個activity的狀態

如果之后用戶通過選擇最初打開task的launcher圖標打開恢復這個task,task會進入前臺并且恢復stack中最頂部的activity。

如果用戶按下back鍵,當前的activity會被從stack中彈出并銷毀

上一個stack中的activity被恢復。

當一個activity被銷毀后,系統不會保持這個activity的狀態

activity可以被實例化多次,甚至從其他的task中。

?

?

?

保存activity的狀態

?

As discussed above, the system's default behavior preserves the state of an activity when it is stopped.?

This way, when users navigate back to a previous activity, its user interface appears the way they left it.?

However, you can—and should—proactively retain the state of your activities using callback methods, in case the activity is destroyed and must be recreated.

正如上面所討論的,當activity進入stop狀態時,系統默認行為保護activity的狀態。

這樣,當用戶導航回退到上一個activity時,它就會顯示離開它時的UI

不管怎樣,你可以也應該有意識的用回調函數保存你activity的狀態 ,以防activity被銷毀并且必須被重新建立

?

?

?

When the system stops one of your activities (such as when a new activity starts or the task moves to the background), the system might destroy that activity completely if it needs to recover system memory.?

When this happens, information about the activity state is lost.?

If this happens, the system still knows that the activity has a place in the back stack, but when the activity is brought to the top of the stack the system must recreate it (rather than resume it).?

In order to avoid losing the user's work, you should proactively retain it by implementing the onSaveInstanceState() callback methods in your activity.

For more information about how to save your activity state, see the Activities document.

當系統停止了你的一個activity時(例如一個新的activity打開了或者task移動到后臺),如果需要恢復系統內存的話,系統也許會完全銷毀這個activity。

當發生這種情況,這個activity的有關狀態的信息將會丟失

如果發生這種情況,系統仍然知道這個activity在back stack占有一個位置,但是當這個activity被帶到stack頂端時,系統必須重新建立它(而不是復用它)。

為了避免丟失你的成果,你應該有意識的通過在你的activity中實現onSaveInstanceState()這個回調函數來保持你的成果。

?

?

本文來自對下面地址的翻譯,英文水平實在有限,希望拍磚同時能給予指正。

http://developer.android.com/guide/components/tasks-and-back-stack.html

?

?

?

?

轉貼請保留以下鏈接

本人blog地址

http://su1216.iteye.com/

http://blog.csdn.net/su1216/

android task與back stack 開發文檔翻譯 - 1


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 曰本一级毛片免费 | 欧美在线观看视频 | 免费在线公开视频 | 女人a级毛片19毛水真多 | 欧美一级高潮片免费的 | www日韩免费高清视频 | 青娱乐综合网 | 久久久久琪琪免费影院 | 久久一本精品 | 天天干天操 | 欧美日韩一区二区三 | jizz18毛片 | 国产丝袜在线 | 欧美视频在线免费看 | 三级理论中文字幕在线播放 | 日韩一二三区视频 | 色婷婷亚洲五月色综合色 | 欧美性一区二区三区 | 国产一级视频 | 欧美日韩一区二区三区在线观看 | 日韩精品福利视频一区二区三区 | 爱草在线| 久久黄视频 | 色福利网 | 日日碰碰| 国产九九精品视频 | 全部免费国产潢色一级 | 欧美亚洲理伦电影毛片在线播放 | 波多久久亚洲精品AV无码 | 亚洲高清成人欧美动作片 | 久久精品视频在线播放 | 一级激情片 | 国产精品成人国产乱一区 | 国产成人精品日本亚洲11 | 成人免费一级毛片在线播放视频 | 国产精品玖玖玖在线观看 | 日韩免费在线 | 国产传媒视频 | 草操影院| 欧美在线一级精品 | 亚洲综合精品一区 |