• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.title=<uses-feature>
2@jd:body
3
4<dl class="xml">
5
6<dt>syntax:</dt>
7<dd>
8<pre class="stx">
9&lt;uses-feature android:<a href="#glEsVersion">glEsVersion</a>="<em>integer</em>"
10              android:<a href="#name">name</a>="<em>string</em>" /&gt;
11</pre>
12</dd>
13
14<dt>contained in:</dt>
15<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
16
17<dt>description:</dt>
18<dd>This element declares a specific feature used by the application.
19Android provides some features that may not be equally supported by all
20Android devices. In a manner similar to the <code><a href="uses-sdk-element.html">&lt;uses-sdk></a></code>
21element, this element allows an application to specify which device-variable
22features it uses. In this way, the application
23will not be installed on devices that do not offer the feature.</p>
24
25<p>For example, an application might specify that it requires a camera with auto-focus capabilities.
26If a device does not provide a camera with auto-focus, then it will not allow
27installation of the application.</p>
28
29<p>In order to maintain strict device compatibility, it's very important that you use
30this element to declare all features that your application uses. Failure to declare
31a feature may result your application being installed on a device
32that does not support the feature and your application failing.</p>
33
34<p>For some features, there may exist a specfic attribute that allows you to define
35a version of the feature, such as the version of Open GL used (declared with
36<a href="#glEsVersion">{@code glEsVersion}</a>). Other features that either do or do not
37exist for a device, such as camera auto-focus, are declared using the
38<a href="#name">{@code name}</a> attribute.</p>
39
40<p>Any software or hardware features that may vary among Android-powered
41devices will be listed on this page among the attributes below. If you see any features
42here that you use in your application, you should include a {@code
43&lt;uses-feature>} element for each one. For example, if your application uses the device
44camera, then you should include the following in your {@code AndroidManifest.xml}:</p>
45
46<pre>
47&lt;uses-feature android:name="android.hardware.camera" />
48</pre>
49
50<p>If you declare "android.hardware.camera", then your application is considered
51compatible with all devices that include a camera, regardless of whether auto-focus is
52available or not. If you also use the auto-focus features (available through the {@link
53android.hardware.Camera Camera API}), then you need to include an additional
54{@code &lt;uses-feature>} element that declares the "android.hardware.camera.autofocus"
55feature. Also note that you must still request the {@link android.Manifest.permission#CAMERA
56CAMERA permission}. Requesting permission grants your application access to the
57appropriate hardware and software, while declaring the features used by
58your application ensures proper device compatibility.</p>
59
60<p>Although the {@code &lt;uses-feature>} element is only activated for devices running
61API Level 4 or higher, it is safe to include this for applications that declare
62a <a href="uses-sdk-element.html#min">{@code minSdkVersion}</a>
63of "3" or lower. Devices running older versions of the platform
64will simply ignore this element, but newer devices will recognize it and enforce
65installation restrictions based on whether the device supports the feature.</p>
66
67<p class="note"><strong>Note:</strong>
68For each feature required by your application, you must include a new {@code
69&lt;uses-feature>} element. Multiple features cannot be declared in one
70instance of this element.</p>
71
72</dd>
73
74
75<dt>attributes:</dt>
76
77<dd>
78<dl class="attr"><dt><a name="glEsVersion"></a>{@code android:glEsVersion}</dt>
79  <dd>The GLES version needed by the application.
80     The higher 16 bits represent the major number and the lower 16 bits
81     represent the minor number. For example, for GL 1.2 referring to
82     0x00000102, the actual value should be set as 0x00010002.
83  </dd>
84</dl>
85</dd>
86
87<dd>
88<dl class="attr"><dt><a name="name"></a>{@code android:name}</dt>
89  <dd>The name of a feature required by the application.
90  The value must be one of the following accepted strings:
91
92  <table>
93    <tr>
94       <th>Feature</th>
95       <th>Value</th>
96       <th>Description</th>
97    </tr><tr>
98       <td rowspan="3">Camera</td>
99       <td>"{@code android.hardware.camera}"</td>
100       <td>The application requires a camera.</td>
101    </tr><tr>
102       <td>"{@code android.hardware.camera.autofocus}"</td>
103       <td>The application requires a camera with auto-focus capability.
104       As a prerequisite, "{@code android.hardware.camera}" must also be declared
105       with a separate {@code &lt;uses-feature>} element.
106       </td>
107     <tr>
108       <td colspan="2">
109         <strong>Note:</strong> Any application that requests the
110         {@link android.Manifest.permission#CAMERA CAMERA permission} but does <em>not</em>
111         declare any camera features with the {@code &lt;uses-feature>} element will be assumed
112         to use all camera features (such as auto-focus). Thus, the application will not
113         be compatible with devices that do not support all features. Please use
114         {@code &lt;uses-feature>} to declare only the camera features that your
115         application needs.
116       </td>
117     </tr>
118    </tr>
119  </table>
120
121  </dd>
122</dl>
123</dd>
124
125<!-- ##api level indication## -->
126<dt>introduced in:</dt>
127<dd>API Level 4</dd>
128
129<dt>see also:</dt>
130<dd>
131  <ul>
132    <li>{@link android.content.pm.ConfigurationInfo}</li>
133  </ul>
134</dd>
135
136</dl>
137