读书人

【通译】(54)manifest元素

发布时间: 2012-08-16 12:02:15 作者: rapoo

【翻译】(54)manifest元素

【翻译】(54)manifest元素

?

see

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

?

原文见

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

?

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

?

* syntax:

?

* 语法:

?

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

?

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

? ? ? ? ? package="string"

? ? ? ? ? android:sharedUserId="string"

? ? ? ? ? android:sharedUserLabel="string resource"?

? ? ? ? ? android:versionCode="integer"

? ? ? ? ? android:versionName="string"

? ? ? ? ? android:installLocation=["auto" | "internalOnly" | "preferExternal"] >

? ? . . .

</manifest>

?

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

?

* contained in:

?

* 被包含在:

?

none

?

?

* must contain:

?

* 必须包含:

?

<application>

?

* can contain:

?

可以包含:

?

<instrumentation>?

<permission>?

<permission-group>?

<permission-tree>?

<uses-configuration>?

<uses-permission>

?

<uses-sdk>

?

* description:

?

* 描述:

?

The root element of the AndroidManifest.xml file. It must contain an <application> element and specify xlmns:android and package attributes.

?

AndroidManifest.xml文件的根元素。它必须包含一个<application>元素并且指定xlmns:android和package属性。

?

* attributes:

?

* 属性:

?

* xmlns:android

?

Defines the Android namespace. This attribute should always be set to "http://schemas.android.com/apk/res/android".

?

定义Android名字空间。该属性应该总是被设置为"http://schemas.android.com/apk/res/android"。

?

* package

?

A full Java-language-style package name for the application. The name should be unique. The name may contain uppercase or lowercase letters ('A' through 'Z'), numbers, and underscores ('_'). However, individual package name parts may only start with letters.

?

一个用于应用程序的完全Java语言风格的包名。该名称应该是唯一的。该名称可以包含大写或小写字母('A'到'Z'),数字,以及下划线('_')。然而,单独的包名部分可能只用字母开头。

?

To avoid conflicts with other developers, you should use Internet domain ownership as the basis for your package names (in reverse). For example, applications published by Google start with com.google. You should also never use the com.example namespace when publishing your applications.

?

为了避免与其它开发者冲突,你应该使用互联网域所有权作为你的包名的基础(反向)。例如,Google发布的应用程序以com.google开头。当你发布你的应用程序时,你还应该从不使用com.example名字空间。

?

The package name serves as a unique identifier for the application. It's also the default name for the application process (see the <application> element's process process attribute) and the default task affinity of an activity (see the <activity> element's taskAffinity attribute).

?

包名担当应用程序的唯一标识符。它还是应用程序进程(见<application>元素的process属性)(注:这里多了一个process)和活动的默认任务关系(见<activity>元素的taskAffinity属性)的默认名称。

?

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

?

Caution: Once you publish your application, you cannot change the package name. The package name defines your application's identity, so if you change it, then it is considered to be a different application and users of the previous version cannot update to the new version.

?

警告:一旦你发布你的应用程序,你不允许改变包名。包名定义你的应用程序的标识符,所以如果你改变它,,那么它被认为是一个不同的应用程序而之前版本的用户不允许更新至这个新版本。

?

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

?

* android:sharedUserId

?

The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that they are also signed by the same certificate. Application with the same user ID can access each other's data and, if desired, run in the same process.

?

将与其它应用程序共享的Linux用户ID的名称。默认,Android赋予每个应用程序它自己的唯一用户ID。然而,如果这个属性被设置为用于两个或多个应用程序的相同的值,那么它们将全都共享同一个ID——假如它们也用相同的证书签名。带有相同用户ID的应用程序可以访问各自的数据,并且如果期待的话,运行在同一个进程中。

?

* android:sharedUserLabel

?

A user-readable label for the shared user ID. The label must be set as a reference to a string resource; it cannot be a raw string.

?

共享用户ID的用户可读标签。该标签必须被设置为指向字符串资源的引用;它不允许是一个原始字符串。

?

This attribute was introduced in API Level 3. It is meaningful only if the sharedUserId attribute is also set.

?

这个属性在API级别3中被引入。它有意义仅当sharedUserId属性页被设置。

?

* android:versionCode

?

An internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute.

?

一个内部版本号。这个号码只被用于决定一个版本是否比另一个更新,较高的号码指示更新的版本。它不是显示给用户的版本号;那个号码由versionName属性设置。

?

The value must be set as an integer, such as "100". You can define it however you want, as long as each successive version has a higher number. For example, it could be a build number. Or you could translate a version number in "x.y" format to an integer by encoding the "x" and "y" separately in the lower and upper 16 bits. Or you could simply increase the number by one each time a new version is released.

?

该值必须被设置为一个整数,诸如"100"。你可以如你所想的那样定义它,只要后续的版本拥有一个较高的数。例如,它应该是一个构建号。或者你可以把一个“x.y”格式的版本号转换为一个整数,通过分别编码x和y在低和高16位中来做到。或者你可以在每次新版本发布时简单地把这个数加一。

?

* android:versionName

?

The version number shown to users. This attribute can be set as a raw string or as a reference to a string resource. The string has no other purpose than to be displayed to users. The versionCode attribute holds the significant version number used internally.

?

显示给用户的版本号。这个属性可以被设置为一个原始字符串或作为指向字符串资源的引用。该字符串除了显示给用户外没有其它目的。versionCode属性持有内部使用的重要版本号。

?

* android:installLocation

?

The default install location for the application.

?

应用程序的默认安装位置。

?

The following keyword strings are accepted:

?

以下关键词字符串被接受:

?

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

?

* ValueDescription

?

* 值 描述

?

* "internalOnly"The application must be installed on the internal device storage only. If this is set, the application will never be installed on the external storage. If the internal storage is full, then the system will not install the application. This is also the default behavior if you do not define android:installLocation.

?

* "internalOnly" 应用程序必须只能被安装在内部存储上。如果它被设置,应用程序将从不被安装在外部存储上。如果内部存储满了,那么系统将不安装该应用程序。它还是默认行为如果你不定义android:installLocation。

?

* "auto"The application may be installed on the external storage, but the system will install the application on the internal storage by default. If the internal storage is full, then the system will install it on the external storage. Once installed, the user can move the application to either internal or external storage through the system settings.

?

* "auto" 应用程序可以安装在外部存储,但系统将默认安装应用程序在内部存储上。如果内部存储满了,那么系统将安装它在外部存储上。一旦被安装,用户可以通过系统设置把应用程序移动到内部或外部存储。

?

* "preferExternal"The application prefers to be installed on the external storage (SD card). There is no guarantee that the system will honor this request. The application might be installed on internal storage if the external media is unavailable or full, or if the application uses the forward-locking mechanism (not supported on external storage). Once installed, the user can move the application to either internal or external storage through the system settings.

?

* "preferExternal" 应用程序倾向于被安装在外部存储(SD卡)上。不保证系统将尊重此请求。应用程序可能被安装在内部存储如果外部媒体不可用或满了,或者如果应用程序使用向前锁定机制(不支持外部存储)。一旦被安装。用户可以通过系统设置移动应用程序到内部或外部存储。(注:旧版本的devguide称为Forward-Locked,新版本devguide改称为Copy-Protected Applications。关于forwardlock / Forward-Locked的解释,见http://zhidao.baidu.com/question/341040465.html,引用如下但不保证其正确性:forwardlock : 禁止将文件移动到手机设备以外的位置。如: PC、SD卡...。Android中:Android market有用到,开发者上传apk时候,可以设置。标识本应用属于受限应用,应用将会被安装到保护目录,只有该应用可以访问代码段和不属于resource的asset资源。那么安装这样的一个 apk,需要设置 FORWARDLOCK 标志位。Android 1.5, PackageManager.FORWARD_LOCK_PACKAGE = 0×00000001;Android 2.2 改成了 INSTALL_FORWARD_LOCK。塞班和其它手机操作系统也有类似概念。)

?

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

?

Caution: If your application uses the Android Market's Copy Protection feature, it cannot be installed to a device's SD card. However, if you use Android Market's Application Licensing instead, your application can be installed to internal or external storage, including SD cards.

?

警告:如果你的应用程序使用Android市场的复制包含特性,那么它不允许安装在一个设备的SD卡上。然而,如果你改为使用Android市场的应用程序许可,那么你的应用程序可以安装到内部或外部存储,包括SD卡。

?

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

?

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

?

Note: By default, your application will be installed on the internal storage and cannot be installed on the external storage unless you define this attribute to be either "auto" or "preferExternal".

?

注意:默认,你的应用程序将被安装在内部存储上,而且不允许安装在外部存储上除非你定义这个属性为"auto"或"preferExternal"。

?

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

?

When an application is installed on the external storage:

?

当一个应用程序被安装在外部存储上时:

?

* The .apk file is saved to the external storage, but any application data (such as databases) is still saved on the internal device memory.

?

* .apk文件被保存到外部存储。但任意应用程序数据(诸如数据库)仍然被保存在内部设备内存上。

?

* The container in which the .apk file is saved is encrypted with a key that allows the application to operate only on the device that installed it. (A user cannot transfer the SD card to another device and use applications installed on the card.) Though, multiple SD cards can be used with the same device.

?

* .apk文件保存在的容器用一个键加密以允许应用程序只操作在安装它的设备上。(一个用户不允许传输SD卡到另一个设备并使用安装在那张卡上的应用程序)。虽然,多张SD卡可以用同一个设备使用。

?

* At the user's request, the application can be moved to the internal storage.

?

* 在用户的请求下,应用程序可以被移动到内部存储中。

?

The user may also request to move an application from the internal storage to the external storage. However, the system will not allow the user to move the application to external storage if this attribute is set to internalOnly, which is the default setting.

?

用户还可能请求一个应用程序从内部存储移动到外部存储。然而,系统将不允许用户把应用程序移动到外部存储,如果这个属性被设置为internalOnly,它是默认设置。

?

Read App Install Location for more information about using this attribute (including how to maintain backward compatibility).

?

阅读应用安装位置以获得关于使用这个属性的更多信息(包括如何维护向后兼容性)。

?

Introduced in: API Level 8.

?

引入:API级别8。

?

* introduced in:

?

* 引入:

?

API Level 1 for all attributes, unless noted otherwise in the attribute description.

?

API级别1对于所有属性,除了在属性描述中另外注明的。

?

* see also:

?

* 另见:

?

<application>

?

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 - 10 Feb 2012 0:44

?

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

?

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/


读书人网 >移动开发

热点推荐