android:taskAffinity && android:allowTaskReparenting

本文深入探讨了Android应用中activity的taskAffinity属性,解释了它如何用于标识activity所属的任务,以及如何通过allowTaskReparenting属性控制activity在任务间的迁移。默认所有activity共享相同的affinity,但可通过设置来改变其行为,实现跨应用任务间灵活的活动管理。
android:taskAffinity
The task that the activity has an affinity for. Activities with the same affinity conceptually belong to the same task (to the same "application" from the user's perspective). The affinity of a task is determined by the affinity of its root activity.
The affinity determines two things — the task that the activity is re-parented to (see the allowTaskReparenting attribute) and the task that will house the activity when it is launched with the FLAG_ACTIVITY_NEW_TASK flag.


By default, all activities in an application have the same affinity. You can set this attribute to group them differently, and even place activities defined in different applications within the same task. To specify that the activity does not have an affinity for any task, set it to an empty string.
If this attribute is not set, the activity inherits the affinity set for the application (see the <application> element's taskAffinity attribute). The name of the default affinity for an application is the package name set by the <manifest> element.
activity用affinity来标识它所属的task.拥有相同affinity的activity属于同一个task。task的affinity由根activity的affinity来定义
affinity决定两件事情:
1、当activity更换从属task时(与allowTaskReparenting相关)
2、当以FLAG_ACTIVITY_NEW_TASK方式加载一个activity时,该activity由放到哪个task中。
缺省的,一个应用的所有activity拥有相同的affinity,你也可以设置这个属性来把他们划分到不同的task里面,甚至把定义在不同应用中的activity放到同一个task.如果要描叙一个activity对所有的task都没有affinity,把他设置为一个空字符串
如果这个属性没有设置,activity从application继承他的taskAffinity属性,taskAffinity的名字缺省跟包名一样的。



android:allowTaskReparenting
Whether or not the activity can move from the task that started it to the task it has an affinity for when that task is next brought to the front — "true" if it can move, and "false" if it must remain with the task where it started.
If this attribute is not set, the value set by the corresponding allowTaskReparenting attribute of the <application> element applies to the activity. The default value is "false".
Normally when an activity is started, it's associated with the task of the activity that started it and it stays there for its entire lifetime. You can use this attribute to force it to be re-parented to the task it has an affinity for when its current task is no longer displayed. Typically, it's used to cause the activities of an application to move to the main task associated with that application.
For example, if an e-mail message contains a link to a web page, clicking the link brings up an activity that can display the page. That activity is defined by the browser application, but is launched as part of the e-mail task. If it's reparented to the browser task, it will be shown when the browser next comes to the front, and will be absent when the e-mail task again comes forward.
The affinity of an activity is defined by the taskAffinity attribute. The affinity of a task is determined by reading the affinity of its root activity. Therefore, by definition, a root activity is always in a task with the same affinity. Since activities with "singleTask" or "singleInstance" launch modes can only be at the root of a task, re-parenting is limited to the "standard" and "singleTop" modes. (See also the launchMode attribute.)
用来描述当那个task下一次切换到前台的时候一个activity是否可以从启动他的task移动到另外一个拥有跟它相同affinity的task,为true表示可以移动,fase表示必须留在启动他的task中
如果activity没有设置这个属性,则它的上一级的application的allowTaskReparenting应用到该application下的所有activity,缺省值为false
一般情况下,当一个activity启动的时候,它和一个task相关,并且它的整个生命周期都呆在这个task中,你也可以使用这个标签来强制他切换到另外一个和它拥有相同affinity的task,切换的时机是当这个task不在显示时。典型的,它用于使一个application的activity移动到和这个application相关的朱task
例如,一个e-mail消息包含一个网页链接,点击这个链接将出发一个activity来显示这个页面,这个activity是有浏览器应用定义的,但是是由e-mail应用程序加载的,所以也属于e-mail这个task。如果这个显示页面的activity切换了其task从属到浏览器,那么当浏览器应用下次在前台显示的时候这个显示页面的activity将会显示,并且当e-mail这个task切换到前台是不会再显示


一个activity的affinity属性由他的taskAffinity属性定义,而一个task的affinity由它的root activtity定义。所以,一个task的root activity总是拥有和它所在task相同的affinity。由于以singleTask和singleInstance启动的ctivity只能是一个task的root activity 所以re-parenting仅限于以standard 和singleTop启动的activity.

基于径向基函数神经网络RBFNN的自适应滑模控制学习(Matlab代码实现)内容概要:本文介绍了基于径向基函数神经网络(RBFNN)的自适应滑模控制方法,并提供了相应的Matlab代码实现。该方法结合了RBF神经网络的非线性逼近能力和滑模控制的强鲁棒性,用于解决复杂系统的控制问题,尤其适用于存在不确定性和外部干扰的动态系统。文中详细阐述了控制算法的设计思路、RBFNN的结构与权重更新机制、滑模面的构建以及自适应律的推导过程,并通过Matlab仿真验证了所提方法的有效性和稳定性。此外,文档还列举了大量相关的科研方向和技术应用,涵盖智能优化算法、机器学习、电力系统、路径规划等多个领域,展示了该技术的广泛应用前景。; 适合人群:具备一定自动控制理论基础和Matlab编程能力的研究生、科研人员及工程技术人员,特别是从事智能控制、非线性系统控制及相关领域的研究人员; 使用场景及目标:①学习和掌握RBF神经网络与滑模控制相结合的自适应控制策略设计方法;②应用于电机控制、机器人轨迹跟踪、电力电子系统等存在模型不确定性或外界扰动的实际控制系统中,提升控制精度与鲁棒性; 阅读建议:建议读者结合提供的Matlab代码进行仿真实践,深入理解算法实现细节,同时可参考文中提及的相关技术方向拓展研究思路,注重理论分析与仿真验证相结合。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值