【翻譯】(66)uses-feature元素

see

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

 

原文見

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

 

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

 

<uses-feature>

 

uses-feature元素

 

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

 

In this document

 

本文目錄

 

* Android Market and Feature-Based Filtering Android市場和基於特性的過濾

* Filtering based on explicitly declared features 基於顯式聲明特性的過濾

* Filtering based on implicit features 基於隱式特性的過濾

* Special handling for Bluetooth feature 藍牙特性的特殊處理

* Testing the features required by your application 測試你的應用程序必需的特性

* Features Reference 特性參考

* Hardware features 硬件特性

* Software features 軟件特性

* Permissions that Imply Feature Requirements 暗示特性要求的權限

 

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

 

* syntax:

 

* 語法:

 

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

 

<uses-feature android:name="string"

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

              android:glEsVersion="integer" />

 

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

 

* contained in:

 

* 被包含在:

 

<manifest>

 

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

 

Android Market and <uses-feature> elements

 

Android市場和<uses-feature>元素

 

Android Market filters the applications that are visible to users, so that users can see and download only those applications that are compatible with their devices. One of the ways Market filters applications is by feature compatibility.

 

Android市場過濾對於用戶可見的應用程序,使用戶只可以看到和下載那些兼容它們的設備的應用程序。市場過濾應用程序的其中一種方式是通過特性兼容性。

 

To do this, Market checks the <uses-feature> elements in each application's manifest, to establish the app's feature needs. Market then shows or hides the application to each user, based on a comparison with the features available on the user's device.

 

爲了做到這點,市場檢查每個應用程序的清單中的<uses-feature>元素,以建立應用的特性需要。然後市場對每個用戶顯示或隱藏應用程序,基於與用戶設備上可用特性的比較。

 

By specifying the features that your application requires, you enable Android Market to present your application only to users whose devices meet the application's feature requirements, rather than presenting it to all users.

 

通過指定你的應用程序必需的特性,你使Android市場只把你的應用程序呈現給持有滿足應用程序要求的設備的用戶,而非把它呈現給所有用戶。

 

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

 

For important information about how Android Market uses features as the basis for filtering, please read Android Market and Feature-Based Filtering, below.

 

想獲得關於Android市場如何使用特性作爲過濾的基礎的重要信息,請閱讀Android市場和下面的基於特性的過濾。

 

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

 

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

 

* description:

 

* 描述:

 

Declares a single hardware or software feature that is used by the application.

 

聲明一個單一硬件或軟件特性,它被應用程序使用。

 

The purpose of a <uses-feature> declaration is to inform any external entity of the set of hardware and software features on which your application depends. The element offers a required attribute that lets you specify whether your application requires and cannot function without the declared feature, or whether it prefers to have the feature but can function without it. Because feature support can vary across Android devices, the <uses-feature> element serves an important role in letting an application describe the device-variable features that it uses.

 

<uses-feature>聲明的目的是爲了告知任意外部實體關於你的應用程序所依賴的硬件和軟件特性集合。該元素提供一個必需屬性,它讓你指定你的應用程序是否必需它和在沒有被聲明特性的情況下不能起作用,或者它是否傾向於擁有特性但可以在沒有它的情況下其作用。因爲特性支持可以跨Android設備而不同,所以<uses-feature>元素起到一個重要的作用,讓一個應用程序描述它使用的設備差別特性。

 

The set of available features that your application declares corresponds to the set of feature constants made available by the Android PackageManager, which are listed for convenience in the Features Reference tables at the bottom of this document.

 

你的應用程序的可用特性集合對應被Android的PackageManager製造的可用特性常量集合,出於方便它們被列舉在本文檔底部的特性參考表格中。

 

You must specify each feature in a separate <uses-feature> element, so if your application requires multiple features, it would declare multiple <uses-feature> elements. For example, an application that requires both Bluetooth and camera features in the device would declare these two elements:

 

你必須在一個分離<uses-feature>元素中指定每個特性,所以如果你的應用程序必需多個特性,它將聲明多個<uses-feature>元素。例如,一個需要設備中藍牙和照相機特性的應用程序將聲明這兩個元素:

 

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

 

<uses-feature android:name="android.hardware.bluetooth" />

<uses-feature android:name="android.hardware.camera" />

 

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

 

In general, you should always make sure to declare <uses-feature> elements for all of the features that your application requires.

 

通常,你應該總是確保爲你的應用程序必需的所有特性聲明<uses-feature>元素。

 

Declared <uses-feature> elements are informational only, meaning that the Android system itself does not check for matching feature support on the device before installing an application. However, other services (such as Android Market) or applications may check your application's <uses-feature> declarations as part of handling or interacting with your application. For this reason, it's very important that you declare all of the features (from the list below) that your application uses.

 

被聲明的<uses-feature>元素只是含信息的,它意味着Android系統自身並不在安裝一個應用程序前檢查在設備上匹配的特性支持。然而,其它服務(諸如Android市場)或應用程序可能檢查你的應用程序的<uses-feature>聲明作爲處理或交互你的應用程序的一部分。因此,非常重要的是你聲明你的應用程序使用的所有特性(從下面的列表中)。

 

For some features, there may exist a specific attribute that allows you to define a version of the feature, such as the version of Open GL used (declared with glEsVersion). Other features that either do or do not exist for a device, such as a camera, are declared using the name attribute.

 

對於一些特性,那裏可能存在一個特定的屬性,它允許你定義特性的版本,諸如Open GL使用的版本(用glEsVersion聲明)。其它對於一個設備或者存在或者不存在的特性,諸如照相機,使用name屬性來聲明。

 

Although the <uses-feature> element is only activated for devices running API Level 4 or higher, it is recommended to include these elements for all applications, even if the minSdkVersion is "3" or lower. Devices running older versions of the platform will simply ignore the element.

 

雖然<uses-feature>元素只對於運行API級別4或更高的設備是被激活的,然而建議對所有應用程序包含這些元素,即便minSdkVersion是"3"或更低。運行較舊版本平臺的設備將簡單地忽略該元素。

 

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

 

Note: When declaring a feature, remember that you must also request permissions as appropriate. For example, you must still request the CAMERA permission before your application can access the camera API. Requesting the permission grants your application access to the appropriate hardware and software, while declaring the features used by your application ensures proper device compatibility.

 

注意:當生命一個特性時,記住你還必須合適地請求權限。例如,你仍必須在你的應用程序可以訪問照相機API之前請求CAMERA權限。請求的權限授權你的應用程序訪問合適的硬件和軟件,同時聲明被你的應用程序使用的特性確保合適的設備兼容性。

 

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

 

* attributes:

 

* 屬性:

 

* android:name

 

Specifies a single hardware or software feature used by the application, as a descriptor string. Valid descriptor values are listed in the Hardware features and Software features tables, below.

 

指定被應用程序使用的單一硬件或軟件特性,作爲一個描述符字符串。可用描述符值被列舉在下面的硬件特性和軟件特性表格中。

 

* android:required

 

Boolean value that indicates whether the application requires the feature specified in android:name.

 

布爾值,它指示應用程序是否需要在android:name中指定的特性。

 

* When you declare "android:required="true" for a feature, you are specifying that the application cannot function, or is not designed to function, when the specified feature is not present on the device.

 

* 當你爲一個特性聲明android:required="true"時(注:此處多一個引號),你正在指定當指定的特性在設備上不存在時,應用程序不能起作用,或者不被設計成起作用。

 

* When you declare "android:required="false" for a feature, it means that the application prefers to use the feature if present on the device, but that it is designed to function without the specified feature, if necessary.

 

* 當你爲一個特性聲明android:required="false",這意味着應用程序傾向於使用特性如果它在設備上存在,但它被設計成沒有指定特性下仍起作用,如果必要的話。

 

The default value for android:required if not declared is "true".

 

android:required的默認值,如果沒有被聲明,爲"true"。

 

* android:glEsVersion

 

The OpenGL ES version required by the application. The higher 16 bits represent the major number and the lower 16 bits represent the minor number. For example, to specify OpenGL ES version 2.0, you would set the value as "0x00020000". To specify OpenGL ES 2.1, if/when such a version were made available, you would set the value as "0x00020001".

 

應用程序必需的OpenGL ES版本。高16位代表主數字而低16位代表次數字。例如,爲了指定OpenGL ES版本2.0,你將設置該值爲"0x00020000"。爲了指定OpenGL ES 2.1,如果/當這麼一個版本被製造出來可用的話(注:這裏的2.1只是個假設),你將設置該值爲"0x00020001"。

 

An application should specify at most one android:glEsVersion attribute in its manifest. If it specifies more than one, the android:glEsVersion with the numerically highest value is used and any other values are ignored.

 

一個應用程序應該在它的清單中指定至少一個android:glEsVersion屬性。如果它指定多於一個,那麼帶有數值上最高的值的android:glEsVersion被使用而其它任意值被忽略。

 

If an application does not specify an android:glEsVersion attribute, then it is assumed that the application requires only OpenGL ES 1.0, which is supported by all Android-powered devices.

 

如果一個應用程序不指定一個android:glEsVersion屬性,那麼它被假設應用程序只需要OpenGL ES 1.0,它被所有基於Android的設備支持。

 

An application can assume that if a platform supports a given OpenGL ES version, it also supports all numerically lower OpenGL ES versions. Therefore, an application that requires both OpenGL ES 1.0 and OpenGL ES 2.0 must specify that it requires OpenGL ES 2.0.

 

一個應用程序可以假設如果一個平臺支持一個給定的OpenGL ES版本,它也支持所有數值上較低的OpenGL ES版本。因此,一個同時需要OpenGL ES 1.0和OpenGL ES 2.0的應用程序必須指定它需要OpenGL ES 2.0。

 

An application that can work with any of several OpenGL ES versions should only specify the numerically lowest version of OpenGL ES that it requires. (It can check at run-time whether a higher level of OpenGL ES is available.)

 

一個可以和幾個OpenGL ES版本中的任意一起工作的應用程序應該只指定它所需要的數值上最低版本的OpenGL ES。(它可以在運行期檢查一個較高級別的OpenGL ES是否可用。)

 

* introduced in:

 

* 引入:

 

API Level 4

 

API級別4

 

* see also:

 

* 另見:

 

* PackageManager

* FeatureInfo

* ConfigurationInfo

* <uses-permission>

* Android Market Filters Android市場過濾器

 

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

 

Android Market and Feature-Based Filtering

 

Android市場和基於特性的過濾

 

Android Market filters the applications that are visible to users, so that users can see and download only those applications that are compatible with their devices. One of the ways Market filters applications is by feature compatibility.

 

Android市場過濾對於用戶可見的應用程序,致使用戶只可以看到並下載那些兼容他們的設備的應用程序。市場過濾應用程序的其中一種方式是通過特性兼容性。

 

To determine an application's feature compatibility with a given user's device, the Android Market service compares:

 

爲了確定一個應用程序對一臺給定的用戶設備的特性兼容性,Android市場服務比較:

 

* Features required by the application — an application declares features in <uses-feature> elements in its manifest 

 

* 應用程序需要的特性——一個應用程序它的清單中的<uses-feature>元素中聲明特性

 

with...

 

和……

 

* Features available on the device, in hardware or software — a device reports the features it supports as read-only system properties.

 

* 在設備上可用的特性,在硬件或軟件方面——一臺設備報告它支持的特性作爲只讀的系統屬性。

 

To ensure an accurate comparison of features, the Android Package Manager provides a shared set of feature constants that both applications and devices use to declare feature requirements and support. The available feature constants are listed in the Features Reference tables at the bottom of this document, and in the class documentation for PackageManager.

 

爲了確保特性的精確比較,Android包管理器提供特性常量的共享集合,應用程序和設備都使用它來聲明特性要求和支持。可用特性常量被列舉在本文檔底部的特性參考表格中,以及在PackageManager的類文檔中。

 

When the user launches the Market application, the application queries the Package Manager for the list of features available on the device by calling getSystemAvailableFeatures(). The Market application then passes the features list up to the Android Market service when establishing the session for the user.

 

當用戶啓動市場應用程序時,應用程序通過調用getSystemAvailableFeatures()詢問包管理器在設備上可用的特性列表。然後市場應用程序把特性列表上傳給Android市場服務,當爲用戶建立會話時。

 

Each time you upload an application to the Android Market Publisher Site, Android Market scans the application's manifest file. It looks for <uses-feature> elements and evaluates them in combination with other elements, in some cases, such as <uses-sdk> and <uses-permission> elements. After establishing the application's set of required features, it stores that list internally as metadata associated with the application .apk and the application version.

 

每當你上傳應用程序到Android市場發佈者網站時,Android市場掃描應用程序的清單文件。它尋找<uses-feature>元素並評估它們結合其它元素,在一些情況下,諸如<uses-sdk>和<uses-permission>。在建立應用程序的必需特性集合後,它內部地存儲那個列表作爲與應用程序.apk和應用程序版本關聯的元數據。

 

When a user searches or browses for applications using the Android Market application, the service compares the features needed by each application with the features available on the user's device. If all of an application's required features are present on the device, Android Market allows the user to see the application and potentially download it. If any required feature is not supported by the device, Android Market filters the application so that it is not visible to the user and not available for download.

 

當一個用戶使用Android市場應用程序搜索或瀏覽應用程序時,服務比較每個應用程序需要的特性和在用戶設備上的可用特性。如果一個應用程序的必需特性存在於該設備上,那麼Android市場允許用戶看到應用程序並隱式地下載它。如果任意必需特性不被設備支持,那麼Android市場過濾該應用程序以使它對於用戶不可見並且不可以下載。

 

Because the features you declare in <uses-feature> elements directly affect how Android Market filters your application, it's important to understand how Android Market evaluates the application's manifest and establishes the set of required features. The sections below provide more information.

 

因爲你在<uses-feature>元素中聲明的特性直接地影響Android市場如何過濾你的應用程序,所以重要的是理解Android市場如何評估應用程序的清單和建立必需特性集合。以下章節提供更多信息。

 

Filtering based on explicitly declared features

 

基於顯式聲明特性的過濾

 

An explicitly declared feature is one that your application declares in a <uses-feature> element. The feature declaration can include an android:required=["true" | "false"] attribute (if you are compiling against API level 5 or higher), which lets you specify whether the application absolutely requires the feature and cannot function properly without it ("true"), or whether the application prefers to use the feature if available, but is designed to run without it ("false").

 

一個顯式聲明特性是你的應用程序在一個<uses-feature>元素中聲明的特性。特性聲明可以包含一個android:required=["true" | "false"]屬性(如果你正在編譯對應API級別5或更高),它讓你指定應用程序是否絕對地需要該特性並且不能在沒有它的情況下正確地起作用("true"),或者應用程序是否傾向於使用該特性如果它可用,但被設計爲沒有它的情況下運行("false")。

 

Android Market handles explicitly declared features in this way:

 

Android市場用這種方式處理顯式聲明特性:

 

* If a feature is explicitly declared as being required, Android Market adds the feature to the list of required features for the application. It then filters the application from users on devices that do not provide that feature. For example:

 

* 如果一個特性被顯式地聲明作爲必需的,那麼Android市場添加特性到應用程序的必需特性列表中。然後它從沒有提供那個特性的設備上的用戶中過濾掉應用程序。例如:

 

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

 

<uses-feature android:name="android.hardware.camera" android:required="true" />

 

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

 

* If a feature is explicitly declared as not being required, Android Market does not add the feature to the list of required features. For that reason, an explicitly declared non-required feature is never considered when filtering the application. Even if the device does not provide the declared feature, Android Market will still consider the application compatible with the device and will show it to the user, unless other filtering rules apply. For example:

 

* 如果一個特性被顯式作爲不是必需的,那麼Android市場不添加該特性到必需特性列表中。因爲那個原因,一個顯式聲明的非必需特性從不被考慮,當過濾應用程序時。即便設備不提供聲明的特性,Android市場將仍然考慮應用程序對設備的兼容以及將把它展示給用戶看,除非其它過濾規則應用了。例如:

 

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

 

<uses-feature android:name="android.hardware.camera" android:required="false" />

 

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

 

* If a feature is explicitly declared, but without an android:required attribute, Android Market assumes that the feature is required and sets up filtering on it.

 

* 如果一個特性被顯式聲明,但不帶一個android:required屬性,那麼Android市場假設特性是必需的並且配置基於它的過濾。

 

In general, if your application is designed to run on Android 1.6 and earlier versions, the android:required attribute is not available in the API and Android Market assumes that any and all <uses-feature> declarations are required.

 

通常,如果你的應用程序被設計爲運行在Android 1.6和更早的版本上,那麼android:required屬性在API中不可用,並且Android市場假設任意和所有<uses-feature>聲明是必需的(注:required的)。

 

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

 

Note: By declaring a feature explicitly and including an android:required="false" attribute, you can effectively disable all filtering on Android Market for the specified feature.

 

注意:通過顯式聲明一個特性和包含一個android:required="false"屬性,你可以有效地屏蔽在Android市場上對特定特性的所有過濾。

 

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

 

Filtering based on implicit features

 

基於隱式特性的過濾

 

An implicit feature is one that an application requires in order to function properly, but which is not declared in a <uses-feature> element in the manifest file. Strictly speaking, every application should always declare all features that it uses or requires, so the absence of a declaration for a feature used by an application should be considered an error. However, as a safeguard for users and developers, Android Market looks for implicit features in each application and sets up filters for those features, just as it would do for an explicitly declared feature.

 

一個隱式特性是指一個應用程序必需的以讓其正常地起作用的特性,但它不被聲明在清單文件中的一個<uses-feature>元素中。嚴格來講,每個應用程序總是應該聲明它使用或需要的所有特性,所以對於一個被應用程序使用的特性的聲明的不存在應該被認爲是一個錯誤。然而,作爲對用戶和開發者的安全措施,Android市場在每個應用程序中尋找隱式特性並且配置對那些特性的過濾,正如它爲一個顯式聲明特性所做的那樣。

 

An application might require a feature but not declare it because:

 

一個應用程序可能需要一個特性但不聲明它,因爲:

 

* The application was compiled against an older version of the Android library (Android 1.5 or earlier) and the <uses-feature> element was not available.

 

* 應用程序被編譯對應Android庫的一個較舊版本(Android 1.5或更早)而<uses-feature>元素還不可用。

 

* The developer incorrectly assumed that the feature would be present on all devices and a declaration was unnecessary.

 

* 開發者不正確地假設特性將出現在所有設備上而不需要一個聲明。

 

* The developer omitted the feature declaration accidentally.

 

* 開發者意外地忽略特性聲明。

 

* The developer declared the feature explicitly, but the declaration was not valid. For example, a spelling error in the <uses-feature> element name or an unrecognized string value for the android:name attribute would invalidate the feature declaration.

 

* 開發者顯式地聲明特性,但聲明不是有效的。例如,在<uses-feature>元素中名稱的拼寫錯誤或者用於android:name屬性的未識別字符串值將無效化該特性聲明。

 

To account for the cases above, Android Market attempts to discover an application's implied feature requirements by examining other elements declared in the manifest file, specifically, <uses-permission> elements.

 

爲了解決上面的情況,Android市場嘗試通過檢查在清單文件中聲明的其它元素,特別地,<uses-permission>元素,來發現一個應用程序的暗示特性要求。

 

If an application requests hardware-related permissions, Android Market assumes that the application uses the underlying hardware features and therefore requires those features, even though there might be no corresponding to <uses-feature> declarations. For such permissions, Android Market adds the underlying hardware features to the metadata that it stores for the application and sets up filters for them.

 

如果一個應用程序請求硬件相關權限,Android市場假設應用程序使用底層硬件特性並且因此需要那些特性,即便可能沒有<uses-feature>聲明對應它。對於這些特性,Android市場添加底層硬件特性到爲應用程序而存儲的元數據,並且對它們配置過濾器。

 

For example, if an application requests the CAMERA permission but does not declare a <uses-feature> element for android.hardware.camera, Android Market considers that the application requires a camera and should not be shown to users whose devices do not offer a camera.

 

例如,如果一個應用程序請求CAMERA權限但不聲明一個用於android.hardware.camera的<uses-feature>元素,那麼Android市場認爲應用程序需要一個照相機並且不應該顯示給不提供照相機的設備的用戶。

 

If you don't want Android Market to filter based on a specific implied feature, you can disable that behavior. To do so, declare the feature explicitly in a <uses-feature> element and include an android:required="false" attribute. For example, to disable filtering derived from the CAMERA permission, you would declare the feature as shown below.

 

如果你比希望Android市場基於一個特定特性來過濾,你可以屏蔽那個行爲。爲了做到這點,顯式地在<uses-feature>元素中聲明該特性幷包含一個android:required="false"屬性。例如,爲了屏蔽繼承自CAMERA權限的過濾,你將聲明該特性如下所示。

 

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

 

<uses-feature android:name="android.hardware.camera" android:required="false" />

 

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

 

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

 

It's important to understand that the permissions that you request in <uses-permission> elements can directly affect how Android Market filters your application. The reference section Permissions that Imply Feature Requirements, below, lists the full set of permissions that imply feature requirements and therefore trigger filtering.

 

這是重要的以理解你在<uses-permission>元素中請求的權限可以直接地影響Android市場如何過濾你的應用程序。下面參考文檔章節,暗示特性要求的權限,列舉暗示特性要求的權限的完全集合以及因此而觸發的過濾。

 

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

 

Special handling for Bluetooth feature

 

對藍牙特性的特殊處理

 

Android Market applies slightly different rules than described above, when determining filtering for Bluetooth.

 

Android市場應用和上面描述的稍微不同的規則,當確定對藍牙的過濾時。

 

If an application declares a Bluetooth permission in a <uses-permission> element, but does not explicitly declare the Bluetooth feature in a <uses-feature> element, Android Market checks the version(s) of the Android platform on which the application is designed to run, as specified in the <uses-sdk> element.

 

如果一個應用程序在<uses-permission>元素中聲明一個藍牙權限,但不顯式地在<uses-feature>元素中聲明藍牙特性,那麼Android市場檢查應用程序被設計以運行在的Android平臺的版本,正如<uses-sdk>元素中指定的那樣。

 

As shown in the table below, Android Market enables filtering for the Bluetooth feature only if the application declares its lowest or targeted platform as Android 2.0 (API level 5) or higher. However, note that Android market applies the normal rules for filtering when the application explicitly declares the Bluetooth feature in a <uses-feature> element.

 

正如下面的表格中所示,Android市場使能對藍牙的過濾,僅當應用程序聲明它的最低或目標平臺爲Android 2.0(API級別5)或更高。然而,注意Android市場應用正常的過濾規則,當應用程序顯式地在一個<uses-feature>元素中聲明藍牙特性。

 

Table 1. How Android Market determines the Bluetooth feature requirement for an application that requests a Bluetooth permission but does not declare the Bluetooth feature in a <uses-feature> element.

 

表1. Android市場如何確定對請求藍牙權限但不在<uses-feature>元素中聲明藍牙特性的應用程序的藍牙特性要求。

 

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

 

* If minSdkVersion is ... or targetSdkVersion is Result

 

* 如果minSdkVersion是…… 或者targetSdkVersion是 結果

 

* <=4 (or uses-sdk is not declared) <=4 Android Market will not filter the application from any devices based on their reported support for the android.hardware.bluetooth feature.

 

* <=4(或uses-sdk沒有被聲明) <=4 Android市場將不從基於它們報告對android.hardware.bluetooth特性的支持的任意設備中過濾掉該應用程序。

 

* <=4 >=5

* >=5 >=5

 

Android Market filters the application from any devices that do not support the android.hardware.bluetooth feature (including older releases).

 

Android市場從不支持android.hardware.bluetooth特性的任意設備(包括較舊的發佈版)中過濾掉該應用程序。

 

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

 

The examples below illustrate the different filtering effects, based on how Android Market handles the Bluetooth feature.

 

下面的示例描繪不同的過濾效果,基於Android市場如何處理藍牙特性。

 

In first example, an application that is designed to run on older API levels declares a Bluetooth permission, but does not declare the Bluetooth feature in a <uses-feature> element.

 

在第一個示例中,一個不被設計爲運行在較舊API級別上的應用程序聲明一個藍牙權限,但不在一個<uses-feature>元素中聲明藍牙特性。

 

Result: Android Market does not filter the application from any device.

 

結果:Android市場不從任意設備中過濾掉該應用程序。

 

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

 

<manifest ...>

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

    <uses-sdk android:minSdkVersion="3" />

    ...

</manifest>

 

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

 

In the second example, below, the same application also declares a target API level of "5".

 

在下面的第二個示例中,相同的應用程序也聲明目標API級別爲"5"。

 

Result: Android Market now assumes that the feature is required and will filter the application from all devices that do not report Bluetooth support, including devices running older versions of the platform.

 

結果:Android市場現在假設特性是必需的並且將從所有不報告藍牙支持的所有設備中過濾應用程序,包括運行較舊平臺版本的設備。

 

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

 

<manifest ...>

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

    <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" />

    ...

</manifest>

 

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

 

Here the same application now specifically declares the Bluetooth feature.

 

這裏相同的應用程序現在特別地聲明藍牙特性。

 

Result: Identical to the previous example (filtering is applied).

 

結果:和前面的例子相同(過濾被應用)

 

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

 

<manifest ...>

    <uses-feature android:name="android.hardware.bluetooth" />

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

    <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" />

    ...

</manifest>

 

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

 

Finally, in the case below, the same application adds an android:required="false" attribute.

 

最後,在下面的例子中,相同的應用程序添加一個android:required="false"屬性。

 

Result: Android Market disables filtering based on Bluetooth feature support, for all devices.

 

結果:Android市場屏蔽基於藍牙特性支持的過濾,對於所有設備。

 

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

 

<manifest ...>

    <uses-feature android:name="android.hardware.bluetooth" android:required="false" />

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

    <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" />

    ...

</manifest>

 

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

 

Testing the features required by your application

 

測試你的應用程序需要的特性

 

You can use the aapt tool, included in the Android SDK, to determine how Android Market will filter your application, based on its declared features and permissions. To do so, run aapt with the dump badging command. This causes aapt to parse your application's manifest and apply the same rules as used by Android Market to determine the features that your application requires.

 

你可以使用aapt工具,它被包括在Android SDK中,以確定Android市場將如何過濾你的應用程序,基於它的被聲明特性和權限。爲了做到這點,用dump badging命令(注:dump badging的字面含義是轉儲商標)運行aapt。這導致aapt解析你的應用程序清單並應用與Android市場相同的規則以確定你的應用程序需要的特性。

 

To use the tool, follow these steps:

 

爲了使用這個工具,遵循這些步驟:

 

1. First, build and export your application as an unsigned .apk. If you are developing in Eclipse with ADT, right-click the project and select Android Tools > Export Unsigned Application Package. Select a destination filename and path and click OK.

 

1. 首先,構建並導出你的應用程序作爲一個未簽名的.apk文件。如果你正在用帶有ADT的Eclipse來開發,請右鍵工程並選擇Android工具>導出未簽名應用程序包。選擇一個目標文件名和路徑並點擊確定。

 

2. Next, locate the aapt tool, if it is not already in your PATH. If you are using SDK Tools r8 or higher, you can find aapt in the <SDK>/platform-tools/ directory.

 

2. 接下來,定位aapt工具,如果它還未在你的PATH中。如果你正在使用SDK工具r8或更高,你可以在<SDK>/platform-tools/目錄中找到aapt。

 

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

 

Note: You must use the version of aapt that is provided for the latest Platform-Tools component available. If you do not have the latest Platform-Tools component, download it using the Android SDK and AVD Manager.

 

注意:你必須使用被提供作爲可用的最新平臺工具組件的aapt版本。如果你沒有最新的平臺工具組件,請使用Android SDK和AVD管理器下載它。

 

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

 

3. Run aapt using this syntax:

 

3. 用這個語法運行aapt:

 

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

 

$ aapt dump badging <path_to_exported_.apk>

 

($ aapt dump badging <導出路徑.apk>)

 

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

 

Here's an example of the command output for the second Bluetooth example, above:

 

這裏是一個對應上面第二個藍牙示例的示例命令行輸出:

 

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

 

$ ./aapt dump badging BTExample.apk

package: name='com.example.android.btexample' versionCode='' versionName=''

uses-permission:'android.permission.BLUETOOTH_ADMIN'

uses-feature:'android.hardware.bluetooth'

sdkVersion:'3'

targetSdkVersion:'5'

application: label='BT Example' icon='res/drawable/app_bt_ex.png'

launchable activity name='com.example.android.btexample.MyActivity'label='' icon=''

uses-feature:'android.hardware.touchscreen'

main

supports-screens: 'small' 'normal' 'large'

locales: '--_--'

densities: '160'

 

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

 

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

 

Features Reference

 

特性參考

 

The tables below provide reference information about hardware and software features and the permissions that can imply them on Android Market.

 

下面的表格提供關於硬件和軟件特性的參考信息以及可以在Android市場上暗示它們的權限。

 

Hardware features

 

硬件特性

 

The table below describes the hardware feature descriptors supported by the most current platform release. To signal that your application uses or requires a hardware feature, declare each value in a android:name attribute in a separate <uses-feature> element.

 

下面的表格描述被大多數當前平臺發行版支持的硬件描述符。爲了告知你的應用程序使用或需要一個硬件特性,請在分離的<uses-feature>元素裏的android:name屬性中聲明每個值。

 

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

 

* Feature Type Feature Descriptor Description Comments

 

* 特性類型 特性描述符 描述註釋

 

* Audio

 

* 音頻

 

* android.hardware.audio.low_latency The application uses a low-latency audio pipeline on the device and is sensitive to delays or lag in sound input or output.

 

* android.hardware.audio.low_latency 應用程序使用設備上的低延遲音頻管道並且是敏感於聲音輸入或輸出的延遲或滯後。

 

* Bluetooth

 

* 藍牙

 

* android.hardware.bluetooth The application uses Bluetooth radio features in the device.

 

* android.hardware.bluetooth 應用程序使用設備中的藍牙無線特性。

 

* Camera

 

* 照相機

 

* android.hardware.camera The application uses the device's camera. If the device supports multiple cameras, the application uses the camera that facing away from the screen.

 

* android.hardware.camera 應用程序使用設備的照相機。如果設備支持多個照相機,那麼該應用程序使用反向於屏幕的照相機。

* android.hardware.camera.autofocus Subfeature. The application uses the device camera's autofocus capability.

 

* android.hardware.camera.autofocus 子特性。應用程序使用設備照相機的自動對焦功能。

 

* android.hardware.camera.flash Subfeature. The application uses the device camera's flash.

 

* android.hardware.camera.flash 子特性。應用程序使用設備照相機的閃光燈。

 

* android.hardware.camera.front Subfeature. The application uses a front-facing camera on the device.

 

* android.hardware.camera.front 子特性。應用程序使用設備上的前向照相機。

 

These subfeatures implicitly declare the android.hardware.camera parent feature, unless declared with android:required="false".

 

這些子特性隱式地聲明android.hardware.camera父特性,除非它用android:required="false"聲明。(注:這是autofocus、flash、front這三個子特性的註釋)

 

* Location

 

* 位置

 

* android.hardware.location The application uses one or more features on the device for determining location, such as GPS location, network location, or cell location.

 

* android.hardware.location 應用程序使用設備上的一個或多個特性以確定位置,諸如GPS位置,網絡位置,或蜂窩位置(注:應該是指蜂窩電話位置,cell phone location)。

 

* android.hardware.location.network Subfeature. The application uses coarse location coordinates obtained from a network-based geolocation system supported on the device.

 

* android.hardware.location.network 子特性。應用程序使用從設備上支持的基於網絡的地理系統中獲得的模糊位置座標。

 

* android.hardware.location.gps Subfeature. The application uses precise location coordinates obtained from a Global Positioning System receiver on the device.

 

* android.hardware.location.gps 子特性。應用程序使用從設備上全球定位系統(注:簡稱爲GPS)接收器中獲得的精確位置座標。

 

These subfeatures implicitly declare the android.hardware.location parent feature, unless declared with android:required="false".

 

這些子特性隱式地聲明android.hardware.location父特性,除非用android:required="false"聲明它。(注:這是network、gps這兩個子特性的註釋)

 

* Microphone

 

* 麥克風

 

* android.hardware.microphone The application uses a microphone on the device.

 

* android.hardware.microphone 應用程序使用設備上的麥克風。

 

* NFC

 

* NFC(注:Near Field Communication,近場通信)

 

* android.hardware.nfc The application uses Near Field Communications radio features in the device.

 

* android.hardware.nfc 應用程序使用設備中的近場通信無線特性。

 

* Sensors

 

* 感應器

 

* android.hardware.sensor.accelerometer The application uses motion readings from an accelerometer on the device.

 

* android.hardware.sensor.accelerometer 應用程序使用來自設備上的加速計(注:即重力加速度傳感器)的動作讀取。

 

* android.hardware.sensor.barometer The application uses the device's barometer.

 

* android.hardware.sensor.barometer 應用程序使用設備的氣壓計。

 

* android.hardware.sensor.compass The application uses directional readings from a magnetometer (compass) on the device.

 

* android.hardware.sensor.compass 應用程序使用來自設備上磁強計(指南針)的方向讀取。

 

* android.hardware.sensor.gyroscope The application uses the device's gyroscope sensor.

 

* android.hardware.sensor.gyroscope 應用程序使用設備的陀螺儀感應器。

 

* android.hardware.sensor.light The application uses the device's light sensor.

 

* android.hardware.sensor.light 應用程序使用設備的光感應器。

 

* android.hardware.sensor.proximity The application uses the device's proximity sensor.

 

* android.hardware.sensor.proximity 應用程序使用設備的接近感應器。

 

* Screen

 

* 屏幕

 

* android.hardware.screen.landscape The application requires landscape orientation.

 

* android.hardware.screen.landscape 應用程序需要寬屏方向。

 

* android.hardware.screen.portrait The application requires portrait orientation.

 

* android.hardware.screen.portrait 應用程序需要豎屏方向。

 

For example, if your app requires portrait orientation, you should declare <uses-feature android:name="android.hardware.screen.portrait"/> so that only devices that support portrait orientation (whether always or by user choice) can install your app. If your application supports both orientations, then you don't need to declare either.

 

例如,如果你的應用需要豎屏方向,那麼你應該聲明<uses-feature android:name="android.hardware.screen.portrait"/>以使只有支持豎屏方向的設備(不管總是或者通過用戶選擇)纔可以安裝你的應用。如果你的應用程序都支持兩種方向,那麼你不需要聲明任何一個。

 

Both orientations are assumed not required, by default, so your app may be installed on devices that support one or both orientations. However, if any of your activities request that they run in a specific orientation, using the android:screenOrientation attribute, then this also declares that the application requires that orientation. For example, if you declare android:screenOrientation with either "landscape", "reverseLandscape", or "sensorLandscape", then your application will be available only to devices that support landscape orientation. As a best practice, you should still declare your requirement for this orientation using a <uses-feature> element. If you declare an orientation for your activity using android:screenOrientation, but don't actually require it, you can disable the requirement by declaring the orientation with a <uses-feature> element and include android:required="false".

 

默認下假設兩個方向是不需要的,所以你的應用可能被安裝在支持一個或兩個方向的設備上。然而,如果你的活動中任意一個請求它們運行在一個特定的方向中,使用android:screenOrientation屬性,那麼它也聲明瞭應用程序需要那個方向。例如,如果你用"landscape","reverseLandscape",或"sensorLandscape"之一聲明android:screenOrientation,然後你的應用程序將只對於支持寬屏方向的設備是可用的。作爲一條最佳實踐,你應該仍然使用<uses-feature>元素聲明你對這個方向的要求。如果你爲你的活動使用android:screenOrientation聲明一個方向,但不是真的需要它,那麼你可以通過用<uses-feature>元素聲明方向以及包含android:required="false"來屏蔽這個要求。

 

For backwards compatibility, any device running a platform version that supports only API level 12 or lower is assumed to support both landscape and portrait.

 

爲了向後兼容性,假設運行只支持API級別12或更低平臺版本的任意設備都支持寬屏和豎屏。

 

* Telephony

 

* 電話

 

* android.hardware.telephony The application uses telephony features on the device, such as telephony radio with data communication services.

 

* android.hardware.telephony 應用程序使用設備上的電話特性,諸如帶數據通信服務的電話無線通信。

 

* android.hardware.telephony.cdma Subfeature. The application uses CDMA telephony radio features on the device.

 

* android.hardware.telephony.cdma 子特性。應用程序使用設備上的CDMA(注:Code Division Multiple Access,碼分多址)電話無線特性。

 

* android.hardware.telephony.gsm Subfeature. The application uses GSM telephony radio features on the device.

 

* android.hardware.telephony.gsm 子特性。應用程序使用設備上的GSM(注:Global System of Mobile communication,全球移動通信系統)電話無線特性。

 

These subfeatures implicitly declare the android.hardware.telephony parent feature, unless declared with android:required="false".

 

這些子特性隱式地聲明android.hardware.telephony父特性,除非用android:required="false"聲明它。(注:這是cdma、gsm這兩個子特性的註釋)

 

* Touchscreen

 

* 觸摸屏

 

* android.hardware.faketouch The application uses basic touch interaction events, such as "click down", "click up", and drag.

 

* android.hardware.faketouch 應用程序使用基本觸摸交互事件,諸如“點擊向下”,“點擊向上”,和拖動。

When declared as required, this indicates that the application is compatible with a device only if it offers an emulated touchscreen ("fake touch" interface), or better. A device that offers a fake touch interface provides a user input system that emulates a subset of touchscreen capabilities. For example, a mouse or remote control that drives an on-screen cursor provides a fake touch interface. If your application requires basic point and click interaction (in other words, it won't work with only a d-pad controller), you should declare this feature. Because this is the minimum level of touch interaction, your app will also be compatible with devices that offer more complex touch interfaces.

 

當它被聲明爲必需的時,這指示應用程序兼容一臺設備,僅當它提供一個模擬的觸摸屏(“僞觸摸”界面),或更好的。一臺提供僞觸摸界面的設備提供一個用戶輸入系統,它模擬觸摸屏功能的一個子集。例如,驅動屏幕上光標的鼠標或遠程控制提供一個僞觸摸界面。如果你的應用程序需要基本的點和點擊交互(換言之,它將不工作於只有一個方向板控制器),你應該聲明此特性。因爲這是觸摸交互的最小級別,所以你的應用還將兼容提供更多複雜觸摸界面的設備。

 

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

 

Note: Because applications require the android.hardware.touchscreen feature by default, if you want your application to be available to devices that provide a fake touch interface, you must also explicitly declare that a touch screen is not required by declaring <uses-feature android:name="android.hardware.touchscreen" android:required="false" />

 

注意:因爲應用程序默認需要android.hardware.touchscreen,如果你希望你的應用程序對於提供一個僞觸摸界面的設備是可用的,那麼你還必須通過聲明<uses-feature android:name="android.hardware.touchscreen" android:required="false" />來顯式地聲明觸摸屏是非必需的。

 

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

 

* android.hardware.faketouch.multitouch.distinct The application performs distinct tracking of two or more "fingers" on a fake touch interface. This is a superset of the faketouch feature.

 

* android.hardware.faketouch.multitouch.distinct 應用程序執行不同的在一個僞觸摸界面上兩個或多個“手指”跟蹤。這是faketouch特性的超集。

 

When declared as required, this indicates that the application is compatible with a device only if it supports touch emulation for events that supports distinct tracking of two or more fingers, or better.

 

當被聲明爲必需時,這指示應用程序兼容一個設備,僅當它支持觸碰模擬以獲得支持兩個或多個手指的區分跟蹤(注:軌跡)的事件,或者更好的。

 

Unlike the distinct multitouch defined by android.hardware.touchscreen.multitouch.distinct, input devices that support distinct multi-touch with a fake touch interface will not support all two-finger gestures, because the input is being transformed to cursor movement on the screen. That is, single finger gestures on such a device move a cursor; two-finger swipes will result in single-finger touch events; other two-finger gestures will result in the corresponding two-finger touch event. An example device that supports distinct multi-touch with a fake touch interface is one that provides a trackpad for cursor movement which also supports two or more fingers.

 

不像被android.hardware.touchscreen.multitouch.distinct定義的區分多觸碰那樣,用一個僞觸碰界面支持區分多點觸碰的輸入設備將不支持所有的兩手指手勢,因爲輸入正在被轉換爲屏幕上的光標移動。就是說,在這樣的設備上單一手指手勢移動光標;兩手指輕掃將導致單一手指的觸碰事件;其它兩手指手勢將導致相應的兩手指觸碰事件。用僞觸碰界面支持區分多點觸碰的一個示例設備是提供軌跡板用於光標移動的設備,它也支持兩個或多個手指。

 

* android.hardware.faketouch.multitouch.jazzhand The application performs distinct tracking of five or more "fingers" on a fake touch interface. This is a superset of the faketouch feature.

 

* android.hardware.faketouch.multitouch.jazzhand 應用程序在一個僞觸摸界面上執行不同的五個或多個“手指”跟蹤。這是faketouch特性的超集。

When declared as required, this indicates that the application is compatible with a device only if it supports touch emulation for events that supports distinct tracking of five or more fingers.

 

當聲明爲必需的時,它指示應用程序兼容一個設備,僅當它支持對支持五個或多個手指的區分跟蹤事件的觸摸模擬。

 

Unlike the distinct multitouch defined by android.hardware.touchscreen.multitouch.jazzhand, input devices that support jazzhand multi-touch with a fake touch interface will not support all five-finger gestures, because the input is being transformed to cursor movement on the screen. That is, single finger gestures on such a device move a cursor; multi-finger gestures will result in single-finger touch events; other multi-finger gestures will result in the corresponding multi-finger touch event. An example device that supports distinct multi-touch with a fake touch interface is one that provides a trackpad for cursor movement which also supports five or more fingers.

 

不像被android.hardware.touchscreen.multitouch.jazzhand定義的區分的多觸碰那樣,用一個僞觸碰界面支持jazzhand多點觸碰的輸入設備將不支持所有五個手指的動作,因爲輸入正在被轉換爲屏幕上的光標移動。就是說,在這樣的設備上的單一手指動作移動一個光標;多手指動作將導致一個單手指觸摸事件;其它多手指手勢將導致相應的多手指觸摸事件。用一個僞觸碰界面支持區分的多觸碰的一個示例設備是提供一個用於光標移動的軌跡板的設備,它也支持五個或更多手指。

 

* android.hardware.touchscreen The application uses touchscreen capabilities for gestures that are more interactive than basic touch events, such as a fling. This is a superset of the basic faketouch feature.

 

* android.hardware.touchscreen 應用程序使用觸摸屏功能以獲得比基本觸摸事件更具交互性的手勢,諸如輕掃(注:fling原意是投擲)。這是基本faketouch特性的超集。

 

By default, your application requires this. As such, your application is not available to devices that provide only an emulated touch interface ("fake touch"), by default. If you want your application available to devices that provide a fake touch interface (or even devices that provide only a d-pad controller), you must explicitly declare that a touch screen is not required, by declaring android.hardware.touchscreen with android:required="false". You should do so even if your application uses—but does not require—a real touch screen interface.

 

默認,你的應用需要它。同樣,默認下你的應用程序對於只提供一個模擬觸摸界面(“僞觸摸”)的設備來說是不可用的。如果你希望你的應用程序可用於提供一個僞觸摸界面的設備(或者甚至是隻提供方向板控制器的設備),你必須顯式地聲明觸摸屏不是必需的,通過用android:required="false"聲明android.hardware.touchscreen。你應該這樣做,即便你的應用程序使用了——但不是必需的——一個真正的觸摸屏界面。

 

If your application does require a touch interface (in order to perform touch gestures such as a fling), then you don't need to do anything, because this is required by default. However, it's best if you explicitly declare all features used by your application, so you should still declare this if your app uses it.

 

如果你的應用程序需要一個觸摸屏界面(爲了執行觸摸動作諸如輕掃),然後你不需要做任何事情,因爲默認這是必需的。然而,如果你顯式地聲明你的應用程序使用的所有特性就最好了,所以你仍然應該聲明它如果你的應用使用了它。

 

If you require more complex touch interaction, such as multi-finger gestures, you should declare the advanced touch screen features below.

 

如果你需要更復雜的觸碰交互,諸如多手指動作,你應該聲明下面的高級觸摸屏特性。

 

* android.hardware.touchscreen.multitouch The application uses basic two-point multitouch capabilities on the device screen, such as for pinch gestures, but does not need to track touches independently. This is a superset of touchscreen feature.

 

* android.hardware.touchscreen.multitouch 應用程序使用設備屏幕上基本的兩點觸碰功能,諸如用於捏手勢,但不需要獨立地跟蹤觸碰。這是觸摸屏特性的超集。

 

This implicitly declares the android.hardware.touchscreen parent feature, unless declared with android:required="false".

 

這隱式地聲明android.hardware.touchscreen父特性,除非用android:required="false"聲明它。(注:這是multitouch的註釋)

 

* android.hardware.touchscreen.multitouch.distinct Subfeature. The application uses advanced multipoint multitouch capabilities on the device screen, such as for tracking two or more points fully independently. This is a superset of multitouch feature.

 

* android.hardware.touchscreen.multitouch.distinct 子特性。應用程序使用設備屏幕上高級多點多觸碰功能,諸如用於完全獨立地跟蹤兩個或多個點。這是多觸碰特性的超集。

 

* android.hardware.touchscreen.multitouch.jazzhand The application uses advanced multipoint multitouch capabilities on the device screen, for tracking up to five points fully independently. This is a superset of distinct multitouch feature.

 

* android.hardware.touchscreen.multitouch.jazzhand 應用程序使用設備屏幕上的高級多點多觸碰功能,用於完全獨立地跟蹤多至五點。這是區分的多觸碰特性的超集。(注:Jazz hands應該是指一種舞蹈手勢)

 

This implicitly declares the android.hardware.touchscreen.multitouch parent feature, unless declared with android:required="false".

 

這隱式地聲明android.hardware.touchscreen.multitouch父特性,除非用android:required="false"聲明它。(注:這是distinct和jazzhand的註釋)

 

* USB

 

* USB

 

* android.hardware.usb.host The application uses USB host mode features (behaves as the host and connects to USB devices).

 

* android.hardware.usb.host 應用程序使用USB主機模式特性(行爲如同主機並且連接到USB設備上)

 

* android.hardware.usb.accessory The application uses USB accessory features (behaves as the USB device and connects to USB hosts).

 

* android.hardware.usb.accessory 應用程序使用USB附件特性(行爲如同USB設備並且連接到USB主機上)。

 

* Wifi

 

* Wifi(注:wireless fidelity的縮寫)

 

* android.hardware.wifi The application uses 802.11 networking (wifi) features on the device.

 

* android.hardware.wifi 應用程序使用設備上的802.11網絡(wifi)特性。

 

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

 

Software features

 

軟件特性

 

The table below describes the software feature descriptors supported by the most current platform release. To signal that your application uses or requires a software feature, declare each value in a android:name attribute in a separate <uses-feature> element.

 

下面的表格描述當前大多數平臺發佈版支持的軟件特性描述符。爲了通知你的應用程序使用或需要一個軟件特性,請在單獨的<uses-feature>元素的android:name屬性中聲明每個值。

 

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

 

* Feature Attribute Value Description Comments

 

* 特性 屬性值 描述 註釋

 

* Live Wallpaper

 

* 動態壁紙

 

* android.software.live_wallpaper The application uses or provides Live Wallpapers.

 

* android.software.live_wallpaper 應用程序使用或提供動態壁紙

 

* SIP/VOIP

 

* SIP/VOIP(注:SIP是Session Initiation Protocol的縮寫,會話發起協議,是用於VoIP最主要的信令協議之一。VOIP是Voice over Internet Protocol的縮寫,意思是IP電話或網絡電話)

 

* android.software.sip The application uses SIP service on the device.

 

* android.software.sip 應用程序使用設備上的SIP服務。

 

* android.software.sip.voip Subfeature. The application uses SIP-based VOIP service on the device.

 

* android.software.sip.voip 子特性。應用程序使用設備上基於SIP的VOIP服務。

 

This subfeature implicitly declares the android.software.sip parent feature, unless declared with android:required="false".

 

這個子特性隱式地聲明android.software.sip父特性,除非用android:required="false"來聲明。

 

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

 

Permissions that Imply Feature Requirements

 

暗示特性要求的權限

 

Some feature constants listed in the tables above were made available to applications after the corresponding API; for example, the android.hardware.bluetooth feature was added in Android 2.2 (API level 8), but the bluetooth API that it refers to was added in Android 2.0 (API level 5). Because of this, some apps were able to use the API before they had the ability to declare that they require the API via the <uses-feature> system.

 

一些列舉在上面表格中的特性常量被變成在對應的API後(注:API級別後?)對應用程序可用;例如,android.hardware.bluetooth,android.hardware.bluetooth特性在Android 2.2中(API級別8)被添加,但它引用的藍牙API在Android 2.0(API級別5)中被添加。因此,一些應用在它們有能力通過<uses-feature>系統聲明它們需要該API之前,有能力使用該API。

 

To prevent those apps from being made available unintentionally, Android Market assumes that certain hardware-related permissions indicate that the underlying hardware features are required by default. For instance, applications that use Bluetooth must request the BLUETOOTH permission in a <uses-permission> element — for legacy apps, Android Market assumes that the permission declaration means that the underlying android.hardware.bluetooth feature is required by the application and sets up filtering based on that feature.

 

爲了阻止那些應用非故意地變得可用,Android市場假設某個硬件相關權限指示底層硬件特性默認是必需的。例如,使用藍牙的應用程序必須在<uses-permission>元素中請求BLUETOOTH權限——對於遺留的應用,Android市場假設權限聲明意味着底層android.hardware.bluetooth特性是應用程序需要的並且配置基於那個特性的過濾。

 

The table below lists permissions that imply feature requirements equivalent to those declared in <uses-feature> elements. Note that <uses-feature> declarations, including any declared android:required attribute, always take precedence over features implied by the permissions below.

 

下面的表格列出暗示了特性要求等價於聲明在<uses-feature>元素中的那些特性要求的權限。注意<uses-feature>聲明,包括任意被聲明瞭的android:required屬性,總是持有比下面權限暗示的特性要高的優先級。

 

For any of the permissions below, you can disable filtering based on the implied feature by explicitly declaring the implied feature explicitly, in a <uses-feature> element, with an android:required="false" attribute. For example, to disable any filtering based on the CAMERA permission, you would add this <uses-feature> declaration to the manifest file:

 

對於以下任意權限,你可以通過顯式聲明(注:此處多了一個explicitly)帶android:required="false"屬性的被暗示特性來屏蔽基於被暗示特性的過濾。例如,爲了屏蔽基於CAMERA權限的任意過濾,你應該添加這個<uses-feature>聲明到清單文件:

 

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

 

<uses-feature android:name="android.hardware.camera" android:required="false" />

 

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

 

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

 

* Category This Permission... Implies This Feature Requirement

 

* 分類 這個權限是…… 暗示這個特性要求(注:此表內的縮寫含義暫時不翻譯)

 

* Bluetooth

 

* 藍牙

 

* BLUETOOTH android.hardware.bluetooth

(See Special handling for Bluetooth feature for details.) (詳細請見對藍牙特性的特殊處理。)

* BLUETOOTH_ADMIN android.hardware.bluetooth

 

* Camera

 

* 照相機

 

* CAMERA android.hardware.camera and 

android.hardware.camera.autofocus

 

* Location

 

* 位置

 

* ACCESS_MOCK_LOCATION android.hardware.location

* ACCESS_LOCATION_EXTRA_COMMANDS android.hardware.location

* INSTALL_LOCATION_PROVIDER android.hardware.location

* ACCESS_COARSE_LOCATION android.hardware.location.network and 

android.hardware.location

* ACCESS_FINE_LOCATION android.hardware.location.gps and 

android.hardware.location

 

* Microphone

 

* 麥克風

 

* RECORD_AUDIO android.hardware.microphone

 

* Telephony

 

* 電話

 

* CALL_PHONE android.hardware.telephony

* CALL_PRIVILEGED android.hardware.telephony

* MODIFY_PHONE_STATE android.hardware.telephony

* PROCESS_OUTGOING_CALLS android.hardware.telephony

* READ_SMS android.hardware.telephony

* RECEIVE_SMS android.hardware.telephony

* RECEIVE_MMS android.hardware.telephony

* RECEIVE_WAP_PUSH android.hardware.telephony

* SEND_SMS android.hardware.telephony

* WRITE_APN_SETTINGS android.hardware.telephony

* WRITE_SMS android.hardware.telephony

 

* Wifi

 

* 無線寬帶

 

* ACCESS_WIFI_STATE android.hardware.wifi

* CHANGE_WIFI_STATE android.hardware.wifi

* CHANGE_WIFI_MULTICAST_STATE android.hardware.wifi

 

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

 

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 - 14 Feb 2012 21:12

 

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

 

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/

發佈了15 篇原創文章 · 獲贊 0 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章