Syntax (syntax ):
<Uses-featureandroid: Name ="String"
Android: required = ["true"
| "False"]
Android: glesversion ="Integer"/>
Included in (contained in ):
<Manifest>
Description ):
This element is used to declare a separate hardware or software feature used by the application.
<Uses-feature> the purpose of the Declaration is to notify other external entities of the hardware and software functions that the application depends on. The required attribute provided by this element allows you to specify whether the application can run normally when the required function does not exist. Because features support different Android devices, the <uses-feature> element is used to describe the important and available device features that the application depends on.
A set of available functions declared by the application correspond to a set of available function constants defined by the packagemanager class of Android. For convenience, these constants are listed in the "function reference" table of "Google Play and function-based filtering.
If an application requires multiple features, you must use the <uses-feature> element to specify each of the required features. For example, you need an application with Bluetooth and camera features on the device, to declare two <uses-feature> elements:
<Uses-feature
Android: Name = "android. Hardware. Bluetooth"
/>
<Uses-feature
Android: Name = "android. Hardware. Camera"
/>
Make sure that the <uses-feature> element is used to declare all functions required by the application.
The declared <uses-feature> element is only informational, which means that the Android system does not check the matching of features supported on the device before installing the application. But other services (such as Google
Play) or the application can check the <uses-feature> Declaration of the application and use it as part of the interaction with the application. For this reason, it is essential to declare all external functions to be used by the application.
For some functions, a specific attribute may exist to define the version of the function, such as the version of Open GL used (declared by glesversion ). In some functions, you do not need to specify the version attribute, such as the camera. You only need to use the name attribute for declaration.
Although the <uses-feature> element is valid only when API level 4 or a later version is run, we recommend that you include this element in all applications, even if the value of minsdkversion is 3 or lower, devices running the old platform version will simply ignore this element.
Note: When declaring a function, remember to apply for the corresponding permissions. For example, you must apply for the camera permission before the application can access the camera API. The permission application allows the application to access the corresponding software/hardware, and declares that the function used by the application is to ensure correct device compatibility.
Attributes (attributes ):
Android: Name
This attribute uses a descriptive string to specify the software/hardware features used by the application. Valid descriptors are listed in the "hardware functions" and "software functions" table of "Google Play and function-based filtering.
Android: Required
This attribute uses a Boolean value to specify whether the application needs the features specified in the Android: Name attribute.
True: if the specified function does not exist on the device, the application cannot run normally.
False: If a specified function exists on the device, the application tends to use this function. However, if necessary, you can design a function that is not specified to run properly.
If not declared, the default value of this attribute is true.
Android: qlesversion
This attribute is used to declare the version of OpenGL ES required by the application. Its 16-bit high represents the main version number, and 16-bit low represents the minor version number. For example, if the version number of OpenGL ES is 2.0, it must be set to 0x00020000. The version number of OpenGL ES to be specified is 2.1. It must be set to 0x00020001.
An application can only specify one android: glesversion attribute in its list. If multiple attributes are specified, only the Android: glesversion attribute with the highest version is used, others will be ignored.
If the application does not specify an Android: glesversion attribute, it is assumed that the application only needs OpenGL es1.0, which is supported on all Android devices.
The application can assume that if a platform supports the preset OpenGL ES version, it also supports all the OpenGL ES versions with lower versions. Therefore, applications that require OpenGL es1.0 and OpenGL es2.0 must specify the required version of OpenGL es2.0.
Applications that can work with any version of OpenGL ES should only specify the minimum version of OpenGL ES required by the application. (The application can check whether a higher version of OpenGL ES is available at runtime .)
Introduced version (introduced in ):
API level 4