任务过程中机器人之间的区别 [英] Difference between task and process in Android

查看:95
本文介绍了任务过程中机器人之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点困惑的任务,并在Android的一个过程之间的区别。

如果我理解正确的一项任务就是一叠活动。从我至今读我的认为的任务看起来是这样的:

  |活性的过程中P1运行|
| b活动的运行过程中P2 |
|活动下在过程P3运行|
 

因此​​,基本上从不同的过程活动可以被包含在相同的堆栈。我是正确?

另一个问题:什么是应用程序上下文的真正含义?这个过程或任务?

最后一个问题:应用程序类(这基本上是一个单身)重新presents流程或任务

解决方案

一切我所了解的,我已经在这个<有学问href="http://developer.android.com/guide/topics/manifest/activity-element.html#reparent">page.

修改:我也只是偶然活动和任务设计指南看起来覆盖你问的具体话题。我学到了很多:)

  

这是不同的,所以基本活动   过程可以包含在相同的   叠加。我是正确?

根据我的理解

,你是正确的。我抓的是,流程是实际执行的单位,而任务即将协会把事情做好。由于从上述第一个例子,如果你创建可打开网页的意图,它创建的Web浏览器的过程中创作的,而是与你的应用程序的任务有关的活动。一个任务,因此,成为活动的运行依赖于所提供的活动应用程序的不同进程的虚拟堆叠。


  

另一个问题:什么是真正的   意思是应用程序上下文的?该   流程或任务?

这是一个很好的问题。基于以上阅读的页面,我的理解是,一个应用程序上下文与进程相关联。我基础上这条线从该页面的跨pretation,但也有可能是其他信息:

  

通常,一个新实例   活动射入过程   应用程序定义它,所以   该活动运行的所有实例   相同的过程


  

和最后一个问题:应用程序   类(这基本上是一个单身)   再presents流程或任务?

使用相同的跨pretation如上,我的猜测,为什么Application对象重新presents一个Singleton是因为所有的应用程序的活动得到运行在一个单一的过程,这个过程是联系在一起的应用程序。我不知道这是一个设计点,但它似乎是,至少,目前的设计的结果。

修改:有一些注意事项这一点。看来,在多个流程应用程序可以为s $ P $垫等等,我的猜测是,应用对象和环境行为的一种机制圈养所有进程在一起。我是pretty的确保您的心理模型已经允许这一点,假设进程是从不同的应用程序,所以它只有很小的差异,允许它放在一个单一的过程。

该清单元素属性的安卓过程的使用说明如下:

  

的名称   方法,其中活动应该   跑。一个通常情况下,所有组件   在默认进程应用程序运行   为应用程序创建。它有   相同的名称作为应用程序   包。元素的   process属性可以设置不同   默认为所有组件。但每次   组件可以覆盖默认,   让你送$ P $垫您   在多个过程中的应用。   如果名称分配给该属性   以一个冒号(':'),一个新的   过程中,私有的应用,   在需要时被创建,   活动运行在这一进程。如果   进程名以小写   字符,该活动将在运行   全球该名称的过程中,提供   它具有这样的权限。本   允许不同的组件   应用程序共享的方法,   减少资源的使用。

I'm a bit confused about the difference between a task and a process in Android.

If I understand correctly a task is just a stack of activities. From what I read so far I think a task could look like this:

| Activity A running in Process P1 |
| Activity B running in Process P2 |
| Activity C running in Process P3 |

So basically activities from different processes can be contained in the same stack. Am I correct?

Another question: What is the real meaning of "application context"? The process or the task?

And final question: The application class (which is basically a singleton) represents the process or the task?

解决方案

Everything I've ever learned about it, I've learned on this page.

Edit: I also just stumbled upon Activity and Task Design Guidelines. It looks to cover the exact topic you asked about. I learned a lot :)

So basically activities from different processes can be contained in the same stack. Am I correct?

Based on my understanding, you are correct. My grasp is that Processes are the units of actual execution while Tasks are about association to get things done. As an example from the aforementioned page, if you create an intent that opens a webpage, the Activity that it creates is created on the web browsers process but is associated with your applications Task. A task, therefore, becomes a virtual stack of Activities running on different processes depending on the application that provided the Activity.


Another question: What is the real meaning of "application context"? The process or the task?

This is a good question. Based on reading the page above, my understanding is that an Applications context is associated with the process. I'm basing that on the interpretation of this line from that page, but there may be other info:

Normally, a new instance of an activity is launched into the process of the application that defined it, so all instances of the activity run in the same process


And final question: The application class (which is basically a singleton) represents the process or the task?

With the same interpretation as above, my guess as to why an Application object represents a Singleton is because all of your applications activities get run on a single process and that process is tied to the Application. I don't know that this is a design point, but it appears to be, at the least, a consequence of the current design.

Edit: There are some caveats to this. It appears that your application can be spread across multiple processes so, my guess is that the Application Object and context act as a mechanism for tethering all the processes together. I'm pretty sure your mental model already allowed for this, assuming the processes were from different applications, so its only a small difference to allow it inside a single process.

The manifest element has the attribute android:process with the description as follows:

The name of the process in which the activity should run. Normally, all components of an application run in the default process created for the application. It has the same name as the application package. The element's process attribute can set a different default for all components. But each component can override the default, allowing you to spread your application across multiple processes. If the name assigned to this attribute begins with a colon (':'), a new process, private to the application, is created when it's needed and the activity runs in that process. If the process name begins with a lowercase character, the activity will run in a global process of that name, provided that it has permission to do so. This allows components in different applications to share a process, reducing resource usage.

这篇关于任务过程中机器人之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆