`

【翻译】(47)activity-alias元素

 
阅读更多

【翻译】(47)activity-alias元素

 

see

http://developer.android.com/guide/topics/manifest/activity-alias-element.html

 

原文见

http://developer.android.com/guide/topics/manifest/activity-alias-element.html

 

-------------------------------

 

<activity-alias>

 

activity-alias元素

 

-------------------------------

 

* syntax:

 

* 语法:

 

<activity-alias android:enabled=["true" | "false"]

                android:exported=["true" | "false"]

                android:icon="drawable resource"

                android:label="string resource"

                android:name="string"

                android:permission="string"

                android:targetActivity="string" >

    . . .

</activity-alias>

 

-------------------------------

 

* contained in:

 

* 被包含在

 

<application>

 

* can contain:

 

* 可以包含:

 

<intent-filter> 

<meta-data>

 

* description:

 

* 描述:

 

An alias for an activity, named by the targetActivity attribute. The target must be in the same application as the alias and it must be declared before the alias in the manifest.

 

由targetActivity属性命名的活动的别名。目标必须是在和别名相同的应用程序中,而且在清单中它必须被声明在别名前。

 

The alias presents the target activity as a independent entity. It can have its own set of intent filters, and they, rather than the intent filters on the target activity itself, determine which intents can activate the target through the alias and how the system treats the alias. For example, the intent filters on the alias may specify the "android.intent.action.MAIN" and "android.intent.category.LAUNCHER" flags, causing it to be represented in the application launcher, even though none of the filters on the target activity itself set these flags.

 

别名把目标活动表现为一个无关的实体。它可以拥有它自己的意图过滤器集合,而且它们,而非目标活动自身上的意图过滤器,决定哪些意图可以通过别名激活目标以及系统如何对待别名。例如,别名上的意图过滤器可能指定"android.intent.action.MAIN"和"android.intent.category.LAUNCHER"标志,导致它呈现在应用程序启动器中,即便在目标活动自身上没有过滤器设置这些标志。

 

With the exception of targetActivity, <activity-alias> attributes are a subset of <activity> attributes. For attributes in the subset, none of the values set for the target carry over to the alias. However, for attributes not in the subset, the values set for the target activity also apply to the alias.

 

除了targetActivity是例外,<activity-alias>的属性是<activity>的属性的子集。对于子集内的属性,为目标而设置的值并不会引申至(注:待考)别名。然而,没有在子集中的属性,为目标活动而设置的值也应用到别名。

 

* attributes:

 

* 属性:

 

* android:enabled

 

Whether or not the target activity can be instantiated by the system through this alias — "true" if it can be, and "false" if not. The default value is "true".

 

目标活动是否可以被系统通过这个别名实例化——"true"如果它可以,而"false"如果不可以。默认值为"true"。

 

The <application> element has its own enabled attribute that applies to all application components, including activity aliases. The <application> and <activity-alias> attributes must both be "true" for the system to be able to instantiate the target activity through the alias. If either is "false", the alias does not work.

 

<application>元素拥有它自己的enabled属性,它应用到所有应用程序组件,包括活动别名。<application>和<activity-alias>属性必须同时是"true"让系统有能力通过别名实例化目标活动。如果有一个是"false",那么别名不工作。

 

* android:exported

 

Whether or not components of other applications can launch the target activity through this alias — "true" if they can, and "false" if not. If "false", the target activity can be launched through the alias only by components of the same application as the alias or applications with the same user ID.

 

其它应用程序的组件是否可以通过这个别名启动目标别名——"true"如果它们可以,而"false"如果不可以。如果为"false",则目标活动只可以被与别名相同的应用程序或带有相同用户ID的应用程序的组件通过别名来启动。

 

The default value depends on whether the alias contains intent filters. The absence of any filters means that the activity can be invoked through the alias only by specifying the exact name of the alias. This implies that the alias is intended only for application-internal use (since others would not know its name) — so the default value is "false". On the other hand, the presence of at least one filter implies that the alias is intended for external use — so the default value is "true".

 

默认值依赖于别名是否包含意图过滤器。缺少任意过滤器意味着该活动只可以通过指定别名的具体名称才能通过别名被调用。这暗示别名倾向于只给应用程序内部使用(因为其它应用程序不知道它的名称)——所以默认值为"false"。另一方面,至少存在一个过滤器暗示过滤器倾向于外部使用——所以默认值为"true"。

 

* android:icon

 

An icon for the target activity when presented to users through the alias. See the <activity> element's icon attribute for more information.

 

用于目标活动的图标,当通过别名呈现给用户。见<activity>元素的icon属性以获得更多信息。

 

* android:label

 

A user-readable label for the alias when presented to users through the alias. See the the <activity> element's label attribute for more information.

 

一个用于别名的用户可读标签,当它通过别名被呈现给用户。见<activity>元素的label属性以获得更多信息。

 

* android:name

 

A unique name for the alias. The name should resemble a fully qualified class name. But, unlike the name of the target activity, the alias name is arbitrary; it does not refer to an actual class.

 

别名的一个唯一名称。名称应该类似一个完全修饰类名。但,不像目标活动的名称,别名名称是任意的;它并不引用一个实际的类。

 

* android:permission

 

The name of a permission that clients must have to launch the target activity or get it to do something via the alias. If a caller of startActivity() or startActivityForResult() has not been granted the specified permission, the target activity will not be activated.

 

权限的名称,客户端必须拥有这个权限来启动目标活动或拿到它来通过别名做一些事情。如果startActivity()或startActivityForResult()的调用方不曾授权指定的权限,那么目标活动将不会被激活。

 

This attribute supplants any permission set for the target activity itself. If it is not set, a permission is not needed to activate the target through the alias.

 

这个属性排挤为目标活动自身设置的任意权限。如果它没有被设置,不需要用一个权限来通过别名激活目标。

 

For more information on permissions, see the Permissions section in the introduction.

 

想获取关于权限的更多信息,请见介绍中的权限章节。

 

* android:targetActivity

 

The name of the activity that can be activated through the alias. This name must match the name attribute of an <activity> element that precedes the alias in the manifest.

 

可以通过别名被激活的活动的名称。这个名称必须匹配在清单中别名前的<activity>元素的name属性。

 

* introduced in:

 

* 引入:

 

API Level 1

 

API级别1

 

* see also:

 

* 另见:

 

<activity>

 

Except as noted, this content is licensed under Apache 2.0. For details and restrictions, see the Content License.

 

除特别说明外,本文在Apache 2.0下许可。细节和限制请参考内容许可证。

 

Android 4.0 r1 - 06 Feb 2012 16:36

 

-------------------------------

 

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

 

(此页部分内容基于Android开源项目,以及使用根据创作公共2.5来源许可证描述的条款进行修改)

 

(本人翻译质量欠佳,请以官方最新内容为准,或者参考其它翻译版本:

* ソフトウェア技術ドキュメントを勝手に翻訳

http://www.techdoctranslator.com/android

* Ley's Blog

http://leybreeze.com/blog/

* 农民伯伯

http://www.cnblogs.com/over140/

* Android中文翻译组

http://androidbox.sinaapp.com/


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics