android task与back stack 开发文档翻译 - 1

  次阅读 作者:智能小宝 来源:互联网 2016-01-14 12:43 我要评论(0)

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.

本站文章信息来源于网络以及网友投稿,本站只负责对文章进行整理、排版、编辑,是出于传递更多信息之目的,并不意味着赞同其观点或证实其内容的真实性。如果您有什么意见或建议,请联系QQ28-1688-302!

人工智能实验室
相关文章相关文章
  • 韩春雨称已能重复实验结果 近期将有消息公布

    韩春雨称已能重复实验结果 近期将有消息公布

  • 未来两年人工智能要怎么走?看这篇就够了

    未来两年人工智能要怎么走?看这篇就够了

  • 英国研发“杀生”机器人 通过生命体获取能量

    英国研发“杀生”机器人 通过生命体获取能量

  • 无人驾驶汽车如何改变城市生活?听听他们怎么说

    无人驾驶汽车如何改变城市生活?听听他们怎么说

网友点评网友点评
阅读推荐阅读推荐

据国外媒体报道,在过去两年内,聊天机器人(chatbot)、人工智能以及机器学习的研发和采用取得了巨大进展。许多初创公司正利用人工智能和...

霍金 视觉中国 图 英国著名物理学家霍金(Stephen Hawking)再次就人工智能(AI)发声,他认为:对于人类来说,强大AI的出现可能是最美妙的...

文|郑娟娟 今年,人工智能(AI) 60岁了。在AI60岁的时候,笔者想要介绍一下AI100,一个刚刚2岁的研究项目,但它的预设寿命是100年,甚至更长...

AlphaGo与李世石的人机大战,为大众迅速普及了人工智能的概念。 但对谷歌而言,除了下围棋,现在的人工智能进展到哪一步了?未来,人工智能...