Application Fundamentals--Launch modes-启动模式

Launch modes-启动模式

There are four different launch modes that can be assigned to an <activity> element's launchMode attribute:翻译:activity元素的launchMode属性可以设定为以下四种值:

"standard" (the default mode)
"singleTop"
"singleTask"
"singleInstance"

The modes differ from each other on these four points:---launchMode属性设定为以上这四个值会导致在以下在四个方面出现不同的差异:

* 一、Which task will hold the activity that responds to the intent ---哪个task将持有被intent激活的这个Activity(实例被压入当前task堆栈还是其他堆栈)?. For the "standard" and "singleTop" modes, it's the task that originated the intent (and called startActivity()) — unless the Intent object contains the FLAG_ACTIVITY_NEW_TASK flag. In that case, a different task is chosen as described in the previous section, Affinities and new tasks.

翻译: "standard" 和 "singleTop"启动模式的Activity组件被激活时候将归属当前task。除非激活这个Activity的intent中的flag值被设定为FLAG_ACTIVITY_NEW_TASK。

In contrast, the "singleTask" and "singleInstance" modes mark activities that are always at the root of a task. They define a task; they're never launched into another task.

翻译:"singleTask" 和 "singleInstance" 启动模式的Activity组件被激活时候始终是一个task的根Activity,这样的Activity是不可能进入其他task堆栈(当前task 堆栈)的,因为它始终是扮演根Activity的角色,如果它进入当前task堆栈的话,它就无法扮演根Activty的角色。所以这样的 Activity实例总是作为根Activity的角色归属于一个自身的task堆栈。
*

二、Whether there can be multiple instances of the activity---是否该Activity组件可以有多个实例存在?. A "standard" or "singleTop" activity can be instantiated many times. They can belong to multiple tasks, and a given task can have multiple instances of the same activity.

翻译:"standard" 和 "singleTop"启动模式的Activity组件可以被多次实例化。在不同的task堆栈中可以重复出现,在一个的task堆栈中也可以有多个同类实例,

In contrast, "singleTask" and "singleInstance" activities are limited to just one instance. Since these activities are at the root of a task, this limitation means that there is never more than a single instance of the task on the device at one time.

翻译:相反,"singleTask" 和 "singleInstance" 启动模式的Activity组件被限制只能存在一个唯一的实例。这是因为这样的实例在自身独立的task堆栈中是根Activity的角色,在一个task中只能存在一个这样的组件实例。
*
三、Whether the instance can have other activities in its task ---该Activity组件实例是否允许它所在的task堆栈中有其他Activity组件实例?. A "singleInstance" activity stands alone as the only activity in its task. If it starts another activity, that activity will be launched into a different task regardless of its launch mode — as if FLAG_ACTIVITY_NEW_TASK was in the intent. In all other respects, the "singleInstance" mode is identical to "singleTask".

翻译:"singleInstance" 启动模式的activity是不允许所处的task中出现其他activity实例的。这就意味着如果说这个activity激活其他activity的时候,被激活的activity是不可能与它同处于一个task堆栈的,被激活的activity只能是归属另外一个新的task堆栈的。这就如同这个 activity所发送的intent对象中的flag属性被设定为FLAG_ACTIVITY_NEW_TASK一样。除了这一点以外,singleInstance" 启动模式 和"singleTask"启动模式是一样的。

The other three modes permit multiple activities to belong to the task. A "singleTask" activity will always be the root activity of the task, but it can start other activities that will be assigned to its task. Instances of "standard" and "singleTop" activities can appear anywhere in a stack.

翻译:其他三个启动属性值的Activity组件实例是允许自己所处的task有多个Activity实例存在的。"singleTask" 启动模式的activity实例在堆栈中是根元素的角色,它可以激活其他 activity并压入到自己所处的task堆栈中。"standard" and "singleTop"启动模式的activity实例可以出现在一个task堆栈中的任意位置。

* 四、Whether a new instance of the class will be launched to handle a new intent ----是否可以再创建一个这样的activity实例来响应intent对象?. For the default "standard" mode, a new instance is created to respond to every new intent. Each instance handles just one intent. For the "singleTop" mode, an existing instance of the class is re-used to handle a new intent if it resides at the top of the activity stack of the target task. If it does not reside at the top, it is not re-used. Instead, a new instance is created for the new intent and pushed on the stack.

翻译:每当接收到一个intent对象的时候,启动模式是默认值"standard"的activity都是新创建一个实例来响应的,启动模式是"singleTop"的activity需要先判断当前task堆栈中的栈顶activity实例的类型是否和它一样,如果一样的话,直接使用栈顶实例来响应,如果不一样的话就创建新创建一个实例来响应,并且把这个新实例压入当前task堆栈。

For example, suppose a task's activity stack consists of root activity A with activities B, C, and D on top in that order, so the stack is A-B-C-D. An intent arrives for an activity of type D. If D has the default "standard" launch mode, a new instance of the class is launched and the stack becomes A-B-C-D-D. However, if D's launch mode is "singleTop", the existing instance is expected to handle the new intent (since it's at the top of the stack) and the stack remains A-B-C-D.

翻译:例如。一个task堆栈中 A是根activity实例,还有B、C、D 三个activity实例,这时候activity D处于栈顶,那么这个堆栈的实例顺序是A-B-C-D。如果这时堆栈顶activity D需要激活一个activity D类型的activity实例,如果activity D的启动模式是"standard"的话,那么Android系统将新建一个这样的实例并且压入当前task堆栈,这时堆栈中的实例顺序将变为A-B-C-D-D。如果activity D的启动模式是"singleTop"的话,那么Android系统直接使用堆顶的这个activity D来应答intent,这时堆栈中的实例顺序依然保持为A-B-C-D。

If, on the other hand, the arriving intent is for an activity of type B, a new instance of B would be launched no matter whether B's mode is "standard" or "singleTop" (since B is not at the top of the stack), so the resulting stack would be A-B-C-D-B.

翻译:如果说intent要激活的是activity B类型的实例,那么Android系统将马上新建一个activity B实例,这时堆栈中的实例顺序将变为A-B-C-D-B。这是由于当前堆栈顶实例不是B,此时根本不会考虑activity B的启动模式是"standard" 还是 "singleTop" 。

As noted above, there's never more than one instance of a "singleTask" or "singleInstance" activity, so that instance is expected to handle all new intents. A "singleInstance" activity is always at the top of the stack (since it is the only activity in the task), so it is always in position to handle the intent. However, a "singleTask" activity may or may not have other activities above it in the stack. If it does, it is not in position to handle the intent, and the intent is dropped. (Even though the intent is dropped, its arrival would have caused the task to come to the foreground, where it would remain.)

翻译:前面我们已经说过:"singleTask" 或 "singleInstance" 启动模式的activity在一个task堆栈中是绝对不可能有多个同类实例的,任何对这样的Activity发出请求的相应都是由这个唯一实例来响应的,"singleInstance" 启动模式的activity总是在task堆栈的顶端,因为它是堆栈中唯一的实例,所以它同时也是根Activity的角色。但是,"singleTask" 启动模式的activity在堆栈中是可以有其他非同类的实例的,如果说这时候有一个intent试图再次激活一个"singleTask" 启动模式的activity,假如这时候恰好堆栈顶实例就是所需要的实例那么由该实例直接响应,如果不是,那么该intent请求失效,虽然失效但是会导致该task来到系统前台。

When an existing activity is asked to handle a new intent, the Intent object is passed to the activity in an onNewIntent() call. (The intent object that originally started the activity can be retrieved by calling getIntent().)

Note that when a new instance of an Activity is created to handle a new intent, the user can always press the BACK key to return to the previous state (to the previous activity). But when an existing instance of an Activity handles a new intent, the user cannot press the BACK key to return to what that instance was doing before the new intent arrived.

需要注意的是:如果是一个新的Activity实例来响应intent请求,用户按下BACK键的时候,界面回到前一个Activity界面,如果Android系统式用当前task堆栈中的现有实例来响应的话,用户即使按下BACK键,也不能回到前一个界面。

For more on launch modes, see the description of the <activity> element.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
混合信号测试的基础是一种测试方法和技术,用于对集成电路中的模拟和数字电路进行测试。混合信号集成电路(ASIC)或混合信号系统芯片(SoC)通常包含模拟和数字电路,而混合信号测试方法旨在确保这两种类型的电路在设计规格和正常工作条件下正常运行。 混合信号测试的基础包括模拟和数字测试方法。模拟测试方法用于检测和测量模拟电路的性能和规格,例如电压、电流、频率等。模拟测试通常使用模拟信号作为输入进行测量,并比较实际测量的结果与预期结果。 数字测试方法用于检测和验证数字电路的功能和正确性。数字测试通常使用数字信号或测试模式作为输入来激活和测试数字电路,然后检测输出是否与预期结果一致。数字测试可以包括逻辑验证、时序验证、故障模拟等方法。 此外,混合信号测试还需要考虑模拟和数字电路之间的交互作用和兼容性。例如,模拟电路的输出可能是数字电路的输入,因此需要确保两种电路之间的接口和信号兼容。 进行混合信号测试还需要采用适当的测试设备和工具。常用的测试设备包括示波器、信号发生器、多用途测试仪器等。测试工具可以包括模拟电压表、逻辑分析仪、模拟信号发生器等。 总之,混合信号测试的基础是将模拟和数字测试方法结合起来,以确保集成电路的模拟和数字电路在设计规格和正常工作条件下正确运行。这是保证集成电路质量和性能的重要步骤。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值