summaryrefslogtreecommitdiffstats
path: root/docs/html/guide/topics/manifest/uses-feature-element.jd
blob: d7fc563ec28bb1a91e0bf8fb63ef9305862edd98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
page.title=<uses-feature>
@jd:body

<dl class="xml">

<dt>syntax:</dt>
<dd>
<pre class="stx">&lt;uses-feature android:<a href="#glEsVersion">glEsVersion</a>="<em>integer</em>"
              android:<a href="#name">name</a>="<em>string</em>"
              android:<a href="#required">required</a>=["true" | "false"] /&gt;</pre>
</dd>

<dt>contained in:</dt>
<dd><code><a
href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>

<dt>description:</dt>
<dd>This element declares a specific feature used by the application.
Android provides some features that may not be equally supported by all
Android devices. In a manner similar to the <code><a
href="uses-sdk-element.html">&lt;uses-sdk></a></code>
element, this element allows an application to specify which device-variable
features it uses. In this way, the application
will not be installed on devices that do not offer the feature.</p>

<p>For example, an application might specify that it requires a camera with auto-focus capabilities.
If a device does not provide a camera with auto-focus, then it will not allow
installation of the application.</p>

<p>In order to maintain strict device compatibility, it's very important that you use
this element to declare all applicable features (listed below) that your application uses. Failure
to declare a feature may result in your application being installed on a device
that does not support the feature and your application failing.</p>

<p>For some features, there may exist a specfic attribute that allows you to define
a version of the feature, such as the version of Open GL used (declared with
<a href="#glEsVersion">{@code glEsVersion}</a>). Other features that either do or do not
exist for a device, such as a camera, are declared using the
<a href="#name">{@code name}</a> attribute.</p>

<p>Any software or hardware features that may vary among Android-powered
devices will be listed on this page among the attributes below. If you see any features
here that you use in your application, you should include a {@code
&lt;uses-feature>} element for each one. For example, if your application uses the device
camera, then you should include the following in your {@code AndroidManifest.xml}:</p>

<pre>
&lt;uses-feature android:name="android.hardware.camera" />
</pre>

<p>If you declare {@code android.hardware.camera} this way, then your application is considered
compatible with all devices that include a camera. If your application also uses auto-focus
features, then you also need to include a
{@code &lt;uses-feature>} element that declares the {@code android.hardware.camera.autofocus}
feature. Also note that you must still request the {@link android.Manifest.permission#CAMERA
CAMERA} permission. 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.</p>

<p>Although the {@code &lt;uses-feature>} element is only activated for devices running 
API Level 4 or higher, it is safe to include this for applications that declare 
a <a href="uses-sdk-element.html#min">{@code minSdkVersion}</a> 
of "3" or lower. Devices running older versions of the platform 
will simply ignore this element, but newer devices will recognize it and enforce 
installation restrictions based on whether the device supports the feature.</p>

<p class="note"><strong>Note:</strong>
For each feature required by your application, you must include a new {@code
&lt;uses-feature>} element. Multiple features cannot be declared in one 
instance of this element.</p>

</dd> 


<dt>attributes:</dt>

<dd>
<dl class="attr">
  <dt><a name="glEsVersion"></a>{@code android:glEsVersion}</dt>
  <dd>The GLES version needed by the application.
     The higher 16 bits represent the major number and the lower 16 bits
     represent the minor number. For example, for GL 1.2,
     the value should be set as {@code 0x00010002}.
  </dd>

  <dt><a name="name"></a>{@code android:name}</dt>
  <dd>The name of a feature required by the application. 
  The value must be one of the following accepted strings:

  <table>
    <tr> 
       <th>Feature</th>
       <th>Value</th> 
       <th>Description</th> 
    </tr><tr>
       <td rowspan="2">Camera</td>
       <td>{@code android.hardware.camera}</td>
       <td>The application requires a camera.</td> 
    </tr><tr>
       <td colspan="2">
         <strong>Note:</strong> Any application that requests the 
         {@link android.Manifest.permission#CAMERA} permission but does <em>not</em>
         declare any camera features with the {@code &lt;uses-feature>} element will be assumed
         to use all camera features (auto-focus and flash). Thus, the application will not
         be compatible with devices that do not support all camera features. Please use
         {@code &lt;uses-feature>} to declare only the camera features that your
         application does need. For instance, if you request the
         {@link android.Manifest.permission#CAMERA} permission, but you do not need auto-focus or
          flash, then declare only the {@code android.hardware.camera} feature&mdash;the other
          camera features that you do not request will no longer be assumed as required.
       </td>
    </tr><tr>
      <td>Camera auto-focus</td>
      <td>{@code android.hardware.camera.autofocus}</td>
      <td>The application requires a camera with auto-focus capability.
       As a prerequisite, {@code android.hardware.camera} must also be declared
       with a separate {@code &lt;uses-feature>} element.
      </td>
    </tr><tr>
      <td>Camera flash</td>
      <td>{@code android.hardware.camera.flash}</td>
      <td>The application requires a camera with a flash.
        As a prerequisite, both {@code android.hardware.camera} and {@code
        android.hardware.camera.autofocus} must also be declared
        with separate {@code &lt;uses-feature>} elements.
      </td>
    </tr><tr>
      <td>Light sensor</td>
      <td>{@code android.hardware.sensor.light}</td>
      <td>The application requires a device with a light sensor.
      </td>
    </tr><tr>
      <td>Proximity sensor</td>
      <td>{@code android.hardware.sensor.proximity}</td>
      <td>The application requires a device with a proximity sensor.
      </td>
    </tr><tr>
      <td>Multitouch screen</td>
      <td>{@code android.hardware.touchscreen.multitouch}</td>
      <td>The application requires a device that supports multitouch.
      </td>
    </tr><tr>
      <td>Telephony</td>
      <td>{@code android.hardware.telephony}</td>
      <td>The application requires a device that includes a telephony radio with data
         communication services.
      </td>
    </tr><tr>
      <td>CDMA telephony</td>
      <td>{@code android.hardware.telephony.cdma}</td>
      <td>The application requires a device that includes a CDMA telephony radio. As a
        prerequisite, {@code android.hardware.telephony} must also be declared
        with a separate {@code &lt;uses-feature>} element.
      </td>
    </tr><tr>
      <td>GSM telephony</td>
      <td>{@code android.hardware.telephony.gsm}</td>
      <td>The application requires a device that includes a GSM telephony radio. As a
        prerequisite, {@code android.hardware.telephony} must also be declared
        with a separate {@code &lt;uses-feature>} element.
      </td>
    </tr>
  </table>
  </dd>

  <dt><a name="required"></a>{@code android:required}</dt>  <!-- added in api level 5 -->
  <dd>Indicates whether the feature is required by the application. This is
    {@code true} by default. <strong>You should not use this attribute for most cases.</strong>
    </p>

    <p>The only situation in which you should set this attribute {@code false} is when your
    application requests the {@link android.Manifest.permission#CAMERA} permission, but will degrade
    gracefully and perform without failure if the device does not have a camera. In this situation,
    you must declare the {@code android.hardware.camera} feature and set the {@code required}
    attribute {@code false}. This is necessary because the {@link
    android.Manifest.permission#CAMERA} permission will automatically turn on the requirement for
    all camera features. So if your application uses this permission but is still compatible with
    devices without a camera, then you must set the {@code required} attribute {@code false} for
    {@code android.hardware.camera} or else it will not install on devices without a camera. Note
    that, while the permission will enable the requirement for <em>all</em> camera features, you
    only need to off the requirement for the basic camera feature.</p>

  </dd>

</dl>
</dd>

<!-- ##api level indication## -->
<dt>introduced in:</dt>
<dd>API Level 4</dd>

<dt>see also:</dt>
<dd>
  <ul>
    <li>{@link android.content.pm.ConfigurationInfo}</li>
  </ul>
</dd>

</dl>