<uses-feature>
句法
<uses-feature android:name="string" android:required=["true" | "false"] android:glEsVersion="integer" />包含于
<manifest>
描述:
声明所使用的应用程序的单个硬件或软件功能。
一个<用途特征>声明的目的是通知一套关于您的应用程序依赖硬件和软件功能的任何外部实体。该元素提供了必需的属性,让您指定应用程序是否需要和不申报的功能不能发挥作用,还是更喜欢有特点,但没有它可以发挥作用。由于功能的支持可以在Android设备各不相同,<用途特征>元素餐厅在让应用程序描述它使用的设备变量功能有重要作用。
在一套应用程序中声明将与设定的被Android软件包管理系统提供的功能的常量,这是在这个文件的底部列出了方便的特点参考表中可用的功能。
您必须指定在一个单独的<使用特征>元素的每个特征,因此,如果您的应用需要多种功能,它会声明多个<使用特征>元素。例如,这需要蓝牙和相机功能的装置中的应用程序将声明这两种元素:
uses-feature android:name="android.hardware.bluetooth" /> <uses-feature android:name="android.hardware.camera" /><用途特征>所有的功能元素应用程序需要在一般情况下,你应该始终确保申报。
android:name
指定由应用程序使用的一个单一的硬件或软件的功能,作为一个描述符串。有效的描述符值是在硬件特性列出和软件功能的表,下面。描述字符串值是区分大小写的。
android:required
布尔值,表示该应用程序是否需要在Android中指定的功能:名称。
当你声明的android:所需=“真”的功能,您可以指定应用程序不能功能,或者没有设计功能,当指定的功能不存在的设备上。
当你声明的android:要求=“假”的功能,这意味着应用程序更倾向于如果存在使用该功能的设备上,但它的设计没有指定功能,如果有必要的功能。
为Android的默认值:如果没有声明需要的是“真”。
android:glEsVersion
由应用所需的OpenGL ES版本。高16位代表的主要数和低16位代表次编号。例如,要指定OpenGL ES版本2.0,您将设置值“0x00020000”,或指定的OpenGL ES 3.0,你可以设置值为“0x00030000”。
应用程序应指定最多一个机器人:在其清单glEsVersion属性。如果指定了多个,在android:glEsVersion用最大的数值是用来和任何其他值都被忽略。
如果应用程序没有指定一个机器人:glEsVersion属性,则假定应用程序只需要的OpenGL ES 1.0,这是所有Android设备的支持。
应用程序可以假设,如果一个平台支持一个给定的OpenGL ES版本,它也支持所有数值较低的OpenGL ES版本。因此,既需要的OpenGL ES 1.0和OpenGL ES 2.0的应用程序必须指定它需要的OpenGL ES 2.0。
可以使用任何数的OpenGL ES版本的工作,应用程序应该只指定数值最低的版本的OpenGL ES的,它需要。 (它可以检查在运行时的OpenGL ES更高水平是否可用。)
有关使用OpenGL ES的,包括如何在运行时检查支持的OpenGL ES版本的详细信息,请参阅的OpenGL ES API的指南。
介绍了:
谷歌播放和基于特征的过滤
谷歌播放过滤是对用户可见,让用户可以看到并下载只有那些与他们的设备兼容的应用程序的应用程序。它的一个应用程序过滤的方法之一是通过功能兼容性。
以确定与给定的用户的设备中的应用的功能兼容性,谷歌播放比较:
应用程序所需的功能 - 应用程序声明在<用途特征>在其清单的元素特点
与...
可在设备上,在硬件或软件功能 - 设备报告,它支持为只读系统属性的功能。
为了确保功能的精确比较,Android的软件包管理器提供了一个共享一套应用程序和设备使用申报功能要求和支持功能常量。可用的功能常量在功能表参照本文件的底部列出,类文档软件包管理系统英寸
当用户启动谷歌播放,应用程序通过调用getSystemAvailableFeatures查询包管理器的设备上可用的功能列表()。该商店的应用程序,然后通过功能列出多达谷歌建立用户会话时播放。
您上传的每个应用程序的谷歌Play开发者控制台时,谷歌播放扫描应用程序的清单文件。它寻找<使用特征>元素,并计算它们与其他元件,在某些情况下,如组合<使用-SDK>和<使用许可权>元素。建立应用程序的集合所需的功能后,内部存储元数据与应用程序.apk文件和应用程序版本的列表。
当用户搜索或浏览了使用谷歌播放应用程序,该服务比较由与用户的设备上可用的功能的每个应用程序所需要的功能。如果所有的应用程序所需的功能存在于设备上,谷歌播放,用户可以查看应用程序和潜在的下载。如果任何需要的功能没有设备支持,谷歌播放过滤应用程序,以便它是不可见的用户,而不是提供下载。
因为你在声明功能<使用特征>元素直接影响谷歌玩就怎么过滤你的应用程序时,了解谷歌玩怎么评估应用程序的清单,并建立集所需的功能是非常重要的。下面的部分提供了更多的信息。
基于过滤上明确宣布特征
显式声明的特点是一个应用程序声明在<用途特征>元素。该功能的声明可以包括机器人:要求=“真”| “假”]属性(如果您正在编译针对API级别5或更高版本),它可以让你指定应用程序是否确实需要此功能,不能没有它正常工作(“真”),或者应用程序是否更愿意使用该功能如果有的话,但被设计为没有它运行(“假”)。
谷歌游戏手柄明确宣布这样的特点:
如果一个功能被显式声明为被要求,谷歌播放添加功能的应用程序所需的功能列表。然后,它过滤掉用户在不提供功能的设备应用程序。例如:
<uses-feature android:name="android.hardware.camera" android:required="true" />如果不被需要的功能已显式声明,谷歌Play不会将功能添加到所需要的功能列表。出于这个原因,过滤应用程序时显式声明的非必需的功能从来没有考虑过。即使设备不提供声明的功能,谷歌播放仍然会考虑应用程序与设备兼容,并会显示给用户,除非其他过滤规则。 例如:
<uses-feature android:name="android.hardware.camera" android:required="false" />如果一个功能被显式声明,但没有一个Android:必需的属性,谷歌播放假定功能是必需的,建立在其上的过滤。
<uses-feature android:name="android.hardware.camera" android:required="false" />要明白,您在<使用许可权>请求权限元素可直接影响谷歌玩就怎么过滤你的应用程序是很重要的。暗示功能要求的参考部分权限,下面,列出了全套暗示功能要求,因此触发过滤权限。
If minSdkVersion is ... |
or targetSdkVersion is |
Result |
---|---|---|
<=4 (or uses-sdk is not declared) | <=4 | 谷歌Play不会过滤来自基于他们对android.hardware.bluetooth报道的功能支持任何设备的应用。 |
<=4 | >=5 | 谷歌播放过滤掉不支持的功能android.hardware.bluetooth(包括旧版本)的任何设备的应用。 |
>=5 | >=5 |
<manifest ...> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-sdk android:minSdkVersion="3" /> ... </manifest>在第二个例子,下面,相同的应用程序也宣告“5”的目标API级别。
<manifest ...> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" /> ... </manifest>在这里,同一个应用程序没有特别声明的蓝牙功能。
<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>最后,在下面的情况下,同样的应用程序添加一个机器人:要求=“false”属性。
<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>测试您的应用程序所需的功能
$ aapt dump badging <path_to_exported_.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'功能参考
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. | |
Bluetooth | android.hardware.bluetooth |
The application uses Bluetooth radio features in the device. | |
android.hardware.bluetooth_le |
The application uses Bluetooth Low Energy radio features in the device. | ||
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.autofocus |
Subfeature. The application uses the device camera's autofocus capability. | These subfeatures implicitly declare theandroid.hardware.camera parent feature, unless declared with android:required="false" . |
|
android.hardware.camera.flash |
Subfeature. The application uses the device camera's flash. | ||
android.hardware.camera.front |
Subfeature. The application uses a front-facing camera on the device. | ||
android.hardware.camera.any |
The application uses at least one camera facing in any direction, or an external camera device if one is connected. Use this in preference toandroid.hardware.camera if a back-facing camera is not required. |
||
android.hardware.camera.external |
The application uses an external camera device if one is connected. | ||
android.hardware.camera.level.full |
The application uses a camera device with FULL -level support. |
||
android.hardware.camera.capability.manual_sensor |
The application uses a a camera device with theMANUAL_SENSOR capability. |
||
android.hardware.camera.capability.manual_post_processing |
The application uses a a camera device with theMANUAL_POST_PROCESSING capability. |
||
android.hardware.camera.capability.raw |
The application uses a a camera device with the RAW capability. |
||
Infrared | android.hardware.consumerir |
The application uses the consumer IR capabilities on the device. | |
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.network |
Subfeature. The application uses coarse location coordinates obtained from a network-based geolocation system supported on the device. | These subfeatures implicitly declare theandroid.hardware.location parent feature, unless declared with android:required="false" . |
|
android.hardware.location.gps |
Subfeature. The application uses precise location coordinates obtained from a Global Positioning System receiver on the device. | ||
Microphone | android.hardware.microphone |
The application uses a microphone on the device. | |
NFC | android.hardware.nfc |
The application uses Near Field Communications radio features in the device. | |
android.hardware.nfc.hce |
The application uses the NFC card emulation feature in the device. | ||
Sensors | android.hardware.sensor.accelerometer |
The application uses motion readings from an accelerometer on the device. | |
android.hardware.sensor.barometer |
The application uses the device's barometer. | ||
android.hardware.sensor.compass |
The application uses directional readings from a magnetometer (compass) on the device. | ||
android.hardware.sensor.gyroscope |
The application uses the device's gyroscope sensor. | ||
android.hardware.sensor.light |
The application uses the device's light sensor. | ||
android.hardware.sensor.proximity |
The application uses the device's proximity sensor. | ||
android.hardware.sensor.stepcounter |
The application uses the device's step counter. | ||
android.hardware.sensor.stepdetector |
The application uses the device's step detector. | ||
Screen | android.hardware.screen.landscape |
The application requires landscape orientation. | For example, if your app requires portrait orientation, you should declare 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 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. |
android.hardware.screen.portrait |
The application requires portrait orientation. | ||
Telephony | android.hardware.telephony |
The application uses telephony features on the device, such as telephony radio with data communication services. | |
android.hardware.telephony.cdma |
Subfeature. The application uses CDMA telephony radio features on the device. | These subfeatures implicitly declare theandroid.hardware.telephony parent feature, unless declared with android:required="false" . |
|
android.hardware.telephony.gsm |
Subfeature. The application uses GSM telephony radio features on the device. | ||
Television | android.hardware.type.television |
The application is designed for a television user experience. | This feature defines "television" to be a typical living room television experience: displayed on a big screen, where the user is sitting far away and the dominant form of input is something like a d-pad, and generally not through touch or a mouse/pointer-device. |
Touchscreen | android.hardware.faketouch |
The application uses basic touch interaction events, such as "click down", "click up", and drag. | 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.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. | 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.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. | 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 |
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. | 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 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. | This implicitly declares theandroid.hardware.touchscreen parent feature, unless declared with android:required="false" . |
|
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. | This implicitly declares theandroid.hardware.touchscreen.multitouch parent feature, unless declared withandroid:required="false" . |
|
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. | ||
USB | android.hardware.usb.host |
The application uses USB host mode features (behaves as the host and connects to USB devices). | |
android.hardware.usb.accessory |
The application uses USB accessory features (behaves as the USB device and connects to USB hosts). | ||
Wi-Fi | android.hardware.wifi |
The application uses 802.11 networking (Wi-Fi) features on the device. | |
android.hardware.wifi.direct |
The application uses the Wi-Fi Direct networking features on the device. |
Feature | Attribute Value | Description |
---|---|---|
App Widgets | android.software.app_widgets |
The application uses or provides App Widgets and should be installed only on devices that include a Home screen or similar location where users can embed App Widgets. |
Device Management | android.software.device_admin |
The application uses device policy enforcement via device administrators. |
Home Screen | android.software.home_screen |
The application behaves as a Home screen replacement and should be installed only on devices that support third-party Home screen apps. |
Input Method | android.software.input_methods |
The application provides a custom input method and should be installed only on devices that support third-party input methods. |
Live Wallpaper | android.software.live_wallpaper |
The application uses or provides Live Wallpapers and should be installed only on devices that support Live Wallpapers. |
SIP/VOIP | android.software.sip |
The application uses SIP service on the device and should be installed only on devices that support SIP. |
android.software.sip.voip |
Subfeature. The application uses SIP-based VOIP service on the device. This subfeature implicitly declares the |
<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 |
|
Wi-Fi | ACCESS_WIFI_STATE |
android.hardware.wifi |
CHANGE_WIFI_STATE |
android.hardware.wifi |
|
CHANGE_WIFI_MULTICAST_STATE |
android.hardware.wifi |