Google Play 会利用应用清单中声明的 <uses-feature> 元素,从不符合应用硬件和软件功能要求的设备上过滤该应用。

通过指定应用所要求的功能,您可以让 Google Play 仅向设备符合应用功能要求的用户(而非所有用户)提供您的应用。

如需了解有关 Google Play 如何根据功能进行过滤的重要信息,请阅读 Google Play 和根据功能进行过滤部分。

语法:
<uses-feature
  android:name="string"
  android:required=["true" | "false"]
  android:glEsVersion="integer" />
包含于:
<manifest>
说明:

声明应用使用的一项硬件或软件功能。

<uses-feature> 声明的用途是向任何外部实体表明应用所依赖的硬件和软件功能集。借助该元素提供的 required 属性,您可以指定应用是否需要声明的功能并且没有该功能便无法正常工作,或者使用该功能只是一种优先选择,没有它仍然可以正常工作。

由于功能支持可能因 Android 设备而异,因此 <uses-feature> 元素发挥的重要作用是,能够让应用描述其使用的随设备而变化的功能。

应用所声明的可用功能集对应 Android PackageManager 提供的功能常量集。本文中的功能参考资料部分已列出这些功能常量。

您必须在单独的 <uses-feature> 元素中指定每个功能,因此如果您的应用需要多个功能,则需声明多个 <uses-feature> 元素。例如,要求设备同时具有蓝牙和相机功能的应用需声明以下两个元素:

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

一般来说,务必要为应用需要的所有功能声明 <uses-feature> 元素。

声明的 <uses-feature> 元素仅供参考,这意味着在安装应用前,Android 系统本身不会检查设备是否提供相应的功能支持。

不过,其他服务(如 Google Play)和应用可能会在处理您的应用或与其交互的过程中检查它的 <uses-feature> 声明。因此,声明您的应用使用的所有功能非常重要。

对于某些功能,您可能可以通过特定属性来定义功能的版本,例如所使用的 Open GL 版本(使用 glEsVersion 声明)。设备具有或不具有的其他功能(如相机)均使用 name 属性进行声明。

尽管只有运行 API 级别 4 或更高版本系统的设备才能激活 <uses-feature> 元素,但请为所有应用加入这些元素(即使 minSdkVersion 为 3 或更低)。运行较低版本平台的设备会忽略该元素。

注意:声明功能时,切记您还必须视情况请求权限。例如,您需要请求 CAMERA 权限,才能让您的应用访问 Camera API。请求权限可允许应用访问相应的硬件和软件。声明应用使用的功能有助于确保设备兼容性。

属性:
android:name
以描述符字符串的形式指定应用使用的单个硬件或软件功能。硬件功能软件功能部分已列出有效的属性值。这些属性值区分大小写。
android:required
表示应用是否需要 android:name 中所指定功能的布尔值。
  • 如果为某项功能声明 android:required="true",表示当设备上没有这项指定的功能时,应用无法正常工作,或依设计预期无法正常工作。
  • 如果为某项功能声明 android:required="false",则表示当设备上有这项指定的功能时应用会使用该功能,但是依设计预期必要时该应用在没有这项指定功能的情况下也可以正常工作。

android:required 的默认值为 "true"

android:glEsVersion
应用需要的 OpenGL ES 版本。高 16 位表示主版本号,低 16 位表示次版本号。例如,如要指定 OpenGL ES 2.0 版,您需将其值设置为“0x00020000”;如要指定 OpenGL ES 3.2,您需将其值设置为“0x00030002”。

应用应在其清单中至多指定一个 android:glEsVersion 属性。如果指定多个该属性,则系统会使用数值最高的 android:glEsVersion,并忽略任何其他值。

如果应用不指定 android: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 指南

引入于:
API 级别 4
另请参阅:

Google Play 和根据功能进行过滤

Google Play 会过滤用户可见的应用,以便用户只能看到和下载与其设备兼容的应用。它过滤应用的方法之一是按功能兼容性进行过滤。

为确定应用与给定用户设备的功能兼容性,Google Play 会比较以下两个方面的功能:

  • 应用所需的功能,在应用清单的 <uses-feature> 元素中声明。
  • 设备上提供的硬件或软件功能,使用只读系统属性报告。

为了准确比较功能,Android 软件包管理器会提供共享的功能常量集,应用和设备均可使用该集来声明功能要求和支持。本文的功能参考资料部分以及 PackageManager 的类文档中已列出这些可用的功能常量。

当用户启动 Google Play 时,应用会通过调用 getSystemAvailableFeatures(),在软件包管理器中查询设备中提供的功能列表。然后,在为用户建立会话时,Google 商店应用会将功能列表向上传递给 Google Play。

每次向 Google Play 管理中心上传应用时,Google Play 都会扫描应用的清单文件。它会寻找 <uses-feature> 元素并在某些情况下结合其他元素(例如 <uses-sdk><uses-permission> 元素)对其进行评估。在建立应用所需的功能集之后,它会在内部将该列表存储为与应用 APK 和应用版本关联的元数据。

当用户使用 Google Play 应用搜索或浏览应用时,该服务会将各应用所需功能与用户设备上提供的功能进行比较。如果设备提供应用所需的全部功能,则 Google Play 会允许用户查看并下载(可能)该应用。

如果设备不支持任何所需功能,则 Google Play 会过滤该应用,令其对用户不可见,也无法供用户下载。

由于您在 <uses-feature> 元素中声明的功能会直接影响 Google Play 对过滤您应用的方式,因此您必须了解 Google Play 如何评估应用的清单以及如何建立所需功能集。以下几节做出了更详细的介绍。

根据明确声明的功能进行过滤

明确声明的功能是指您的应用在 <uses-feature> 元素中声明的功能。如果您编译的应用面向 API 级别 5 或更高版本,功能声明可包含 android:required=["true" | "false"] 属性。

您可通过此属性指定应用是硬性需要该功能,没有该功能便无法正常工作(设置为 "true" 时),还是应用在具有该功能时会使用它,但依设计预期在没有该功能时也能正常运行(设置为 "false" 时)。

Google Play 按以下方式处理明确声明的功能:

  • 如果您将某项功能明确声明为所需功能(如下例所示),则 Google Play 会将该功能添加至应用的所需功能列表。然后,它会从不提供该功能的设备上过滤该应用,使其对用户不可见。
    <uses-feature android:name="android.hardware.camera.any" android:required="true" />
    
  • 如果您将某个功能明确声明为非所需功能(如下例所示),则 Google Play 不会将该功能添加至所需功能列表。因此,在过滤应用时,Google Play 从不会考虑明确声明的非所需功能。即使设备不提供声明的功能,Google Play 仍会考虑与设备兼容的应用并将其显示给用户,除非有其他适用的过滤规则。
    <uses-feature android:name="android.hardware.camera" android:required="false" />
    
  • 如果您明确声明某个功能,但未给其加入 android:required 属性,则 Google Play 会假定该功能是所需功能,并对其设置过滤。

一般而言,如果您的应用设计为在 Android 1.6 及更低版本上运行,则 API 中不提供 android:required 属性,Google Play 会假定所有 <uses-feature> 声明均为所需功能。

注意:通过明确声明某个功能并加入 android:required="false" 属性,您可以在 Google Play 上有效停用所有针对指定功能的过滤。

根据隐含功能进行过滤

隐含功能是指应用正常工作所需,但未在清单文件的 <uses-feature> 元素中进行声明的功能。严格地讲,最好让每个应用都务必声明其使用或需要的所有功能,对于未声明应用使用的某项功能的情况,可视为错误。

不过,作为向用户和开发者提供的一种保障措施,Google Play 会寻找每个应用中的隐含功能并为这些功能设置过滤,就像其为明确声明功能所做的那样。

应用可能需要某个功能,但由于一些原因而不声明它,例如以下原因:

  • 应用的编译目标是旧版本的 Android 内容库(Android 1.5 或更低版本),<uses-feature> 元素不可用。
  • 开发者误认为所有设备都提供该功能,没必要进行声明。
  • 开发者无意中遗漏了功能声明。
  • 开发者已明确声明该功能,但声明无效。例如,<uses-feature> 元素名称拼写错误或无法识别的 android:name 属性字符串值都会令功能声明无效。

为将这些情况考虑在内,Google Play 会尝试检查清单文件中声明的其他元素(具体而言,即 <uses-permission> 元素),从而发现应用的隐含功能要求。

如果应用请求硬件相关权限,则 Google Play 会假定该应用使用基础的硬件功能,并因此需要这些功能,即使可能没有相应的 <uses-feature> 声明。对于此类权限,Google Play 会向其为应用存储的元数据中添加这些基础的硬件功能,并为这类功能设置过滤。

例如,如果应用请求 CAMERA 权限,则 Google Play 会假定该应用需要使用后置(面向外的)摄像头,即使该应用没有针对 android.hardware.camera 声明 <uses-feature> 元素。因此,Google Play 会过滤掉没有后置摄像头的设备。

如果您不想让 Google Play 根据特定隐含功能进行过滤,请在 <uses-feature> 元素中显式声明该功能并加入 android:required="false" 属性。例如,如需停用 CAMERA 权限隐含的过滤,请声明以下功能:

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

注意:您在 <uses-permission> 元素中请求的权限可能会直接影响 Google Play 对您应用的过滤方式。隐含功能要求的权限部分列出了隐含功能要求并因此触发过滤的全部权限。

针对蓝牙功能的特殊处理

在确定针对蓝牙的过滤时,Google Play 应用的规则与上例所述的规则略有差异。

如果某个应用在 <uses-permission> 元素中声明蓝牙权限,但未在 <uses-feature> 元素中明确声明蓝牙功能,则 Google Play 会按照 <uses-sdk> 元素中指定的步骤,检查作为应用设计运行目标的 Android 平台版本。

如下表所示,只有当应用声明其最低或目标平台为 Android 2.0(API 级别 5)或更高版本时,Google Play 才会启用针对蓝牙功能的过滤。但请注意,当应用在 <uses-feature> 元素中明确声明蓝牙功能时,Google Play 会应用正常的过滤规则。

表 1. Google Play 如何为已请求蓝牙权限却未在 <uses-feature> 元素中声明蓝牙功能的应用确定蓝牙功能要求。

如果 minSdkVersion 为 ... 并且 targetSdkVersion 结果
<=4,或者未声明 <uses-sdk> <=4 Google Play 不会根据设备所报告的对 android.hardware.bluetooth 功能的支持情况,从任何设备中过滤该应用。
<=4 >=5 Google Play 会从任何不支持 android.hardware.bluetooth 功能(包括旧版本)的设备中过滤该应用。
>=5 >=5

以下示例根据 Google Play 对蓝牙功能的处理方式说明不同的过滤效果。

在第一个示例中,设计为在旧版 API 级别上运行的应用声明了蓝牙权限,但未在 <uses-feature> 元素中声明蓝牙功能。
结果: Google Play 不会从任何设备中过滤该应用。
<manifest ...>
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-sdk android:minSdkVersion="3" />
    ...
</manifest>
在第二个示例中,同一应用还声明了目标 API 级别“5”。
Google Play 现认为该功能是所需功能,将从所有不报告蓝牙支持的设备(包括运行旧版本平台的设备)上过滤该应用。
<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>
最后,在以下示例中,同一应用添加了一个 android:required="false" 属性。
结果:Google Play 针对所有设备停用根据蓝牙功能支持进行过滤。
<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>

测试应用需要的功能

您可以使用 Android SDK 中包含的 aapt 工具确定 Google Play 如何根据应用声明的功能和权限对其进行过滤。如需执行该操作,请使用 dump badging 命令运行 aapt。这会使 aapt 解析应用的清单,并应用与 Google Play 所用相同的规则,从而确定应用需要的功能。

如要使用该工具,请按以下步骤操作:

  1. 构建应用并将其导出为未签名 APK。如果您使用 Android Studio 进行开发,请使用 Gradle 构建您的应用,具体操作步骤如下:
    1. 打开项目并选择 Run > Edit Configurations
    2. 选择靠近 Run/Debug Configurations 窗口左上角的加号。
    3. 选择 Gradle
    4. Name 中输入“Unsigned APK”。
    5. Gradle project 部分选择您的模块。
    6. Tasks 中输入“assemble”。
    7. 选择 OK 完成新配置。
    8. 确保已在工具栏中选择 Unsigned APK 运行配置,然后选择 Run > Run 'Unsigned APK'
    您可以在 <ProjectName>/app/build/outputs/apk/ 目录中找到未签名的 APK。
  2. 如果 aapt 工具尚未出现在您的 PATH 中,请定位该工具。如果您使用的是 SDK Tools r8 或更高版本,则可以在 <SDK>/build-tools/<tools version number> 目录中找到 aapt

    注意:您必须使用为最新可用 Build-Tools 组件提供的 aapt 版本。如果您没有最新的 Build-Tools 组件,请使用 Android SDK 管理器下载该组件。

  3. 使用以下语法运行 aapt
$ aapt dump badging <path_to_exported_.apk>

以下是针对上文第二个蓝牙示例的命令输出示例:

$ ./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'

功能参考资料

下文提供有关硬件功能、软件功能以及隐含具体功能要求的权限集的参考信息。

硬件功能

此部分介绍最新平台版本所支持的硬件功能。如要指出您的应用使用或需要某项硬件功能,请在 android:name 属性中声明以 "android.hardware" 开头的相应值。每次声明硬件功能时,请使用单独的 <uses-feature> 元素。

音频硬件功能

android.hardware.audio.low_latency
应用使用设备的低延迟时间音频管道,该管道可以减少处理声音输入或输出时的滞后和延迟。
android.hardware.audio.output
应用使用设备的扬声器、音频耳机插孔、蓝牙流式传输能力或类似机制传输声音。
android.hardware.audio.pro
应用使用设备的高端音频功能和性能能力。
android.hardware.microphone
应用使用设备的麦克风记录音频。

蓝牙硬件功能

android.hardware.bluetooth
应用使用设备的蓝牙功能,通常用于与其他支持蓝牙的设备进行通信。
android.hardware.bluetooth_le
应用使用设备的低功耗蓝牙无线电功能。

相机硬件功能

注意:为了避免 Google Play 对您的应用进行不必要的过滤,请向您的应用即使不具备也可正常运行的任何相机功能添加 android:required="false"。否则,Google Play 会假定该功能是必备功能,并阻止不支持该功能的设备获取您的应用。

大屏幕支持

某些相机功能在部分大屏幕设备上不受支持。Chromebook 通常不具备后置(面向外的)摄像头、自动对焦功能或闪光灯。但是,Chromebook 配有前置(面向用户的)摄像头,并且通常会连接到外接摄像头。

如需提供基本的相机支持并使您的应用可供尽可能多的设备使用,请在应用清单中添加以下相机功能设置:

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

调整功能设置以支持应用的用例。但是,为了使您的应用可供尽可能多的设备使用,应始终添加 required 属性,以明确指定某项功能是否是必备功能。

功能列表
android.hardware.camera.any

应用使用设备的其中一个摄像头或为设备连接的外接摄像头。如果您的应用不要求摄像头必须是后置(朝向外面)摄像头或前置(朝向用户)摄像头,请使用此功能来代替 android.hardware.cameraandroid.hardware.camera.front

CAMERA 权限意味着您的应用也使用 android.hardware.camera。除非使用 android:required="false" 声明 android.hardware.camera,否则后置摄像头就是一项必备功能。

android.hardware.camera

应用使用设备的后置(朝向外面)摄像头。

注意:像 Chromebook 这样只有前置(朝向用户)摄像头的设备不支持此功能。如果您的应用可以使用任何摄像头(无论其朝向哪个方向),请使用 android.hardware.camera.any

注意CAMERA 权限意味着后置摄像头是一项必备功能。为了帮助在应用清单包含 CAMERA 权限时在 Google Play 上正确进行过滤,请明确指定您的应用使用 camera 功能,并指明此功能是否属于必备功能,例如:
<uses-feature android:name="android.hardware.camera" android:required="false" />

android.hardware.camera.front

应用使用设备的前置(朝向用户)摄像头。

CAMERA 权限意味着您的应用也使用 android.hardware.camera。除非使用 android:required="false" 声明 android.hardware.camera,否则后置摄像头就是一项必备功能。

注意:如果您的应用使用 android.hardware.camera.front,但未使用 android.required="false" 明确声明 android.hardware.camera,Google Play 就会将没有后置摄像头的设备(例如 Chromebook)过滤掉。如果您的应用支持只有前置摄像头的设备,请使用 android.required="false" 声明 android.hardware.camera 以防止不必要的过滤。

android.hardware.camera.external

应用与用户为设备连接的外接摄像头进行通信。此功能无法保证外接摄像头可供您的应用使用。

CAMERA 权限意味着您的应用也使用 android.hardware.camera。除非使用 android:required="false" 声明 android.hardware.camera,否则后置摄像头就是一项必备功能。

android.hardware.camera.autofocus

应用使用设备相机支持的自动对焦功能。

注意CAMERA 权限意味着自动对焦是一项必备功能。当您的应用清单包含 CAMERA 权限时,为了确保在 Google Play 上进行正确的过滤,请明确指定您的应用使用自动对焦功能,并指明此功能是否属于必备功能,例如:
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />

android.hardware.camera.flash

应用使用设备相机支持的闪光灯功能。

android.hardware.camera.capability.manual_post_processing

应用使用设备相机支持的 MANUAL_POST_PROCESSING 功能。

您的应用可通过该功能替换相机的自动白平衡功能。使用 android.colorCorrection.transformandroid.colorCorrection.gains 以及 TRANSFORM_MATRIXandroid.colorCorrection.mode

android.hardware.camera.capability.manual_sensor

应用使用设备相机支持的 MANUAL_SENSOR 功能。

此功能隐含对自动曝光锁定 (android.control.aeLock) 的支持,从而让摄像头的曝光时间和灵敏度一直固定在特定值。

android.hardware.camera.capability.raw

应用使用设备相机支持的 RAW 功能。

此功能暗示设备可以保存 DNG(原始)文件。设备的摄像头会提供应用直接处理这些原始图像所需的 DNG 相关元数据。

android.hardware.camera.level.full
应用使用由设备的至少一个摄像头提供的 FULL 级别的图片拍摄支持。FULL 支持包括快速捕捉功能、逐帧控制和手动后期处理控制。请参阅 INFO_SUPPORTED_HARDWARE_LEVEL_FULL

设备界面硬件功能

android.hardware.type.automotive

将应用设计为在车辆内的一组屏幕上显示其界面。 用户通过硬按钮、轻触、旋转控制器以及类鼠标界面与应用进行交互。车辆的屏幕通常出现在车辆的中控台或仪表板中。这些屏幕的尺寸和分辨率通常有限。

注意 :由于用户是在驾车时使用此类应用界面,因此应用必须尽量不要让驾驶员分心。

android.hardware.type.television

(已废弃;请改用 android.software.leanback。)

将应用设计为在电视上显示其界面。此功能将“电视”定义为一种典型的起居室电视体验:应用在大屏幕上显示、用户坐在远处,主流输入形式是类似方向键的设备,而不是鼠标、指示器或触摸设备。

android.hardware.type.watch
将应用设计为在手表上显示其界面。用户会将手表佩戴在身体(例如手腕)上。用户在很近的距离与设备互动。

指纹硬件功能

android.hardware.fingerprint
应用使用设备的生物识别硬件读取指纹。

手柄硬件功能

android.hardware.gamepad
应用捕获来自设备本身或其所连接手柄的游戏控制器输入。

红外线硬件功能

android.hardware.consumerir
应用使用设备的红外线 (IR) 功能,通常是为了与其他消费 IR 设备进行通信。

定位硬件功能

android.hardware.location
应用使用设备上的一项或多项功能来确定位置,例如 GPS 位置、网络位置或小区位置。
android.hardware.location.gps

应用使用通过设备的全球定位系统 (GPS) 接收器获得的精确位置坐标。

通过使用此功能,应用暗示其还会使用 android.hardware.location 功能(除非使用属性 android:required="false" 声明此父功能)。

android.hardware.location.network

应用使用通过设备所支持的基于网络的地理定位系统获得的粗略位置坐标。

通过使用此功能,应用暗示其还会使用 android.hardware.location 功能(除非使用属性 android:required="false" 声明此父功能)。

NFC 硬件功能

android.hardware.nfc
应用使用设备的近距离无线通信 (NFC) 功能。
android.hardware.nfc.hce

应用使用托管在设备上的 NFC 卡模拟。

OpenGL ES 硬件功能

android.hardware.opengles.aep
应用使用安装在设备上的 OpenGL ES Android 扩展包

传感器硬件功能

android.hardware.sensor.accelerometer
应用使用通过设备的加速度计读取的运动信息,以检测设备的当前屏幕方向。例如,应用可以使用加速计读数,以确定何时切换至纵向或横向方向。
android.hardware.sensor.ambient_temperature
应用使用设备的外界(环境)温度传感器。例如,天气应用可以报告室内或室外温度。
android.hardware.sensor.barometer
应用使用设备的气压计。例如,天气应用可以报告气压。
android.hardware.sensor.compass
应用使用设备的磁力计(指南针)。例如,导航应用可以显示用户当前面朝的方向。
android.hardware.sensor.gyroscope
应用使用设备的陀螺仪来检测旋转和倾斜,从而形成一个六轴定向系统。通过使用该传感器,当需要切换至纵向或横向方向时,应用可以更流畅地检测出来。
android.hardware.sensor.hifi_sensors
应用使用设备的高保真 (Hi-Fi) 传感器。例如,游戏应用可以检测用户的高精度移动。
android.hardware.sensor.heartrate
应用使用设备的心率监测器。例如,健身应用可以报告用户心率随时间的变化趋势。
android.hardware.sensor.heartrate.ecg
应用使用设备的心电图 (ECG) 心率传感器。例如,健身应用可以报告更详细的用户心率信息。
android.hardware.sensor.light
应用使用设备的光传感器。例如,应用可以根据环境光照条件显示两种配色方案中的一种。
android.hardware.sensor.proximity
应用使用设备的近程传感器。例如,在检测到用户的手持设备贴近身体时,电话应用可以关闭设备的屏幕。
android.hardware.sensor.relative_humidity
应用使用设备的相对湿度传感器。例如,天气应用可以利用湿度来计算和报告当前露点。
android.hardware.sensor.stepcounter
应用使用设备的计步器。例如,健身应用可以报告用户需要走多少步才能达到每天的计步目标。
android.hardware.sensor.stepdetector
应用使用设备的步测器。例如,健身应用可以利用每步的间隔时间来推测用户正在进行的锻炼类型。

屏幕硬件功能

android.hardware.screen.landscape
android.hardware.screen.portrait

应用要求设备使用纵向或横向方向。 如果您的应用同时支持这两种屏幕方向,则无需声明任一功能。

例如,如果您的应用要求纵向方向,则应声明以下功能,使得只有支持纵向方向(始终或由用户选择)的设备才能运行您的应用:

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

默认情况下假定两种屏幕方向均非必须使用的方向,这样您的应用就可以安装在支持一种或同时支持两种方向的设备上。不过,如果应用的任一 Activity 利用 android:screenOrientation 属性请求在特定屏幕方向下运行,则此声明意味着您的应用需要该屏幕方向。

例如,如果您使用 "landscape""reverseLandscape""sensorLandscape" 声明 android:screenOrientation,则您的应用只能安装在支持横向方向的设备上。

最佳做法是,使用 <uses-feature> 元素声明对该屏幕方向的要求。如果您使用 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". 为 activity 声明屏幕方向

For backward compatibility, any device running Android 3.1 (API level 12) or lower supports both landscape and portrait orientations.

Telephony hardware features

android.hardware.telephony
The app uses the device's telephony features, such as telephony radio with data communication services.
android.hardware.telephony.cdma

The app uses the Code Division Multiple Access (CDMA) telephony radio system.

By using this feature, an app implies that it also uses the android.hardware.telephony feature, unless this parent feature is declared with android:required="false".

android.hardware.telephony.gsm

The app uses the Global System for Mobile Communications (GSM) telephony radio system.

By using this feature, an app implies that it also uses the android.hardware.telephony feature, unless this parent feature is declared with android:required="false".

Touchscreen hardware features

android.hardware.faketouch

The app uses basic touch interaction events, such as tapping and dragging.

When declared as required, this feature indicates that the app is compatible with a device only if that device has an emulated "fake touch" touchscreen or has an actual touchscreen.

A device that offers a fake touch interface provides a user input system that emulates a subset of a touchscreen's capabilities. For example, a mouse or remote control might drive an on-screen cursor.

If your app requires basic point and click interaction and doesn't work with only a D-pad controller, declare this feature. Because this is the minimum level of touch interaction, you can also use an app that declares this feature on devices that offer more complex touch interfaces.

Apps require the android.hardware.faketouch feature by default. If you want your app to be limited to devices that only have a touchscreen, you must explicitly declare that touchscreen is required as follows:

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

All apps that don't explicitly require android.hardware.touchscreen, as shown in the following example, also work on devices with android.hardware.faketouch.

<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
android.hardware.faketouch.multitouch.distinct

The app tracks two or more distinct "fingers" on a fake touch interface. This is a superset of the android.hardware.faketouch feature. When declared as required, this feature indicates that the app is compatible with a device only if that device emulates distinct tracking of two or more fingers or has an actual touchscreen.

Unlike the distinct multitouch defined by android.hardware.touchscreen.multitouch.distinct, input devices that support distinct multitouch with a fake touch interface don't support all two-finger gestures, because the input is transformed to cursor movement on the screen. That is, single-finger gestures on such a device move a cursor, two-finger swipes cause single-finger touch events to occur, and other two-finger gestures trigger the corresponding two-finger touch events.

A device that provides a two-finger touch trackpad for cursor movement can support this feature.

android.hardware.faketouch.multitouch.jazzhand

The app tracks five or more distinct "fingers" on a fake touch interface. This is a superset of the android.hardware.faketouch feature. When declared as required, this feature indicates that the app is compatible with a device only if that device emulates distinct tracking of five or more fingers or has an actual touchscreen.

Unlike the distinct multitouch defined by android.hardware.touchscreen.multitouch.jazzhand, input devices that support jazzhand multitouch with a fake touch interface don't support all five-finger gestures, because the input is transformed to cursor movement on the screen. That is, single-finger gestures on such a device move a cursor, multi-finger gestures cause single-finger touch events to occur, and other multi-finger gestures trigger the corresponding multi-finger touch events.

A device that provides a five-finger touch trackpad for cursor movement can support this feature.

android.hardware.touchscreen

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

By default, all apps require this feature and therefore aren't available to devices that provide only an emulated "fake touch" interface. You can make your app available on devices that provide a fake touch interface, or even on devices that provide only a D-pad controller, by explicitly declaring that a touchscreen is not required using android.hardware.touchscreen with android:required="false". Add this declaration if your app uses, but doesn't require, a real touchscreen interface. All apps that don't explicitly require android.hardware.touchscreen also work on devices with android.hardware.faketouch.

If your app in fact requires a touch interface, such as to perform more advanced touch gestures like flings, then you don't need to declare any touch interface features, because they're required by default. However, it's best if you explicitly declare all features that your app uses.

If you require more complex touch interaction, such as multi-finger gestures, declare that your app uses advanced touchscreen features.

android.hardware.touchscreen.multitouch

The app uses the device's basic two-point multitouch capabilities, such as for pinch gestures, but the app doesn't need to track touches independently. This is a superset of the android.hardware.touchscreen feature.

By using this feature, an app implies that it also uses the android.hardware.touchscreen feature, unless this parent feature is declared with android:required="false".

android.hardware.touchscreen.multitouch.distinct

The app uses the device's advanced multitouch capabilities for tracking two or more points independently. This feature is a superset of the android.hardware.touchscreen.multitouch feature.

By using this feature, an app implies that it also uses the android.hardware.touchscreen.multitouch feature, unless this parent feature is declared with android:required="false".

android.hardware.touchscreen.multitouch.jazzhand

The app uses the device's advanced multitouch capabilities for tracking five or more points independently. This feature is a superset of the android.hardware.touchscreen.multitouch feature.

By using this feature, an app implies that it also uses the android.hardware.touchscreen.multitouch feature, unless this parent feature is declared with android:required="false".

USB hardware features

android.hardware.usb.accessory
The app behaves as a USB device and connects to USB hosts.
android.hardware.usb.host
The app uses the USB accessories that are connected to the device. The device serves as the USB host.

Vulkan hardware features

android.hardware.vulkan.compute
The app uses Vulkan compute features. This feature indicates that the app requires the hardware-accelerated Vulkan implementation. The feature version indicates which level of optional compute features the app requires beyond the Vulkan 1.0 requirements. For example, if your app requires Vulkan compute level 0 support, declare the following feature:
<uses-feature
    android:name="android.hardware.vulkan.compute"
    android:version="0"
    android:required="true" />
For more details about the feature version, see FEATURE_VULKAN_HARDWARE_COMPUTE.
android.hardware.vulkan.level
The app uses Vulkan level features. This feature indicates that the app requires the hardware-accelerated Vulkan implementation. The feature version indicates which level of optional hardware features the app requires. For example, if your app requires Vulkan hardware level 0 support, declare the following feature:
<uses-feature
    android:name="android.hardware.vulkan.level"
    android:version="0"
    android:required="true" />
For more information about the feature version, see FEATURE_VULKAN_HARDWARE_LEVEL.
android.hardware.vulkan.version
The app uses Vulkan. This feature indicates that the app requires the hardware-accelerated Vulkan implementation. The feature version indicates the minimum version of Vulkan API support the app requires. For example, if your app requires Vulkan 1.0 support, declare the following feature:
<uses-feature
    android:name="android.hardware.vulkan.version"
    android:version="0x400003"
    android:required="true" />
For more details about the feature version, see FEATURE_VULKAN_HARDWARE_VERSION.

Wi-Fi hardware features

android.hardware.wifi
The app uses 802.11 networking (Wi-Fi) features on the device.
android.hardware.wifi.direct
The app uses the Wi-Fi Direct networking features on the device.

Software features

This section presents the software features supported by the most current platform release. To indicate that your app uses or requires a software feature, declare the corresponding value, beginning with "android.software", in an android:name attribute. Each time you declare a software feature, use a separate <uses-feature> element.

Communication software features

android.software.sip
The app uses Session Initiation Protocol (SIP) services. By using SIP, the app can support internet telephony operations, such as video conferencing and instant messaging.
android.software.sip.voip

The app uses SIP-based Voice Over Internet Protocol (VoIP) services. By using VoIP, the app can support real-time internet telephony operations, such as two-way video conferencing.

By using this feature, an app implies that it also uses the android.software.sip feature, unless this parent feature is declared with android:required="false".

android.software.webview
The app displays content from the internet.

Custom input software features

android.software.input_methods
The app uses a new input method, which the developer defines in an InputMethodService.

Device management software features

android.software.backup
The app includes logic to handle a backup and restore operation.
android.software.device_admin
The app uses device administrators to enforce a device policy.
android.software.managed_users
The app supports secondary users and managed profiles.
android.software.securely_removes_users
The app can permanently remove users and their associated data.
android.software.verified_boot
The app includes logic to handle results from the device's verified boot feature, which detects whether the device's configuration changes during a restart operation.

Media software features

android.software.midi
The app connects to musical instruments or outputs sound using the Musical Instrument Digital Interface (MIDI) protocol.
android.software.print
The app includes commands for printing documents displayed on the device.
android.software.leanback
The app is designed to run on Android TV devices.
android.software.live_tv
The app streams live television programs.

Screen interface software features

android.software.app_widgets
The app uses or provides App Widgets and is intended only for devices that include a Home screen or similar location where users can embed App Widgets.
android.software.home_screen
The app behaves as a replacement to the device's Home screen.
android.software.live_wallpaper
The app uses or provides wallpapers that include animation.

Permissions that imply feature requirements

Some hardware and software feature constants are made available to applications after the corresponding API. Because of this, some apps might use the API before they can declare that they require the API using the <uses-feature> system.

To prevent those apps from being made available unintentionally, Google Play 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, Google Play 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. Table 2 lists permissions that imply feature requirements equivalent to those declared in <uses-feature> elements.

<uses-feature> declarations, including any declared android:required attribute, always take precedence over features implied by the permissions in table 2. For any of these permissions, you can disable filtering based on the implied feature by explicitly declaring the feature in a <uses-feature> element with the required attribute set to false.

For example, to disable filtering based on the CAMERA permission, add the following <uses-feature> declarations to the manifest file:

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

Caution: If your app targets Android 5.0 (API level 21) or higher and uses the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to receive location updates from the network or a GPS, respectively, you must also explicitly declare that your app uses the android.hardware.location.network or android.hardware.location.gps hardware features.

Table 2. Device permissions that imply device hardware use.

Category Permission Implied 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
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

android.hardware.location.network (Only when target API level is 20 or lower.)

ACCESS_FINE_LOCATION

android.hardware.location

android.hardware.location.gps (Only when target API level is 20 or lower.)

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