| page.title=<uses-feature> |
| @jd:body |
| |
| <dl class="xml"> |
| |
| <dt>syntax:</dt> |
| <dd> |
| <pre class="stx"><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"] /></pre> |
| </dd> |
| |
| <dt>contained in:</dt> |
| <dd><code><a |
| href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a></code></dd> |
| |
| <div class="sidebox-wrapper"> |
| <img id="rule" src="{@docRoot}assets/images/grad-rule-qv.png"> |
| <div id="qv-sub-rule"> |
| <img src="{@docRoot}assets/images/icon_market.jpg" style="float:left;margin:0;padding:0;"> |
| <p style="color:#669999;">Android Market and <uses-feature> elements</p> |
| <p>Android Market filters the applications that are visible to users, so |
| that users can see and download only those applications that are compatible with their |
| devices. One of the ways Market filters applications is by feature compatibility.</p> |
| |
| <p style="margin-top:1em;">To do this, Market checks the |
| <code><uses-feature></code> elements in each application's manifest, to |
| establish the app's feature needs. Market then shows or hides the application to |
| each user, based on a comparison with the features available on the user's |
| device. </p> |
| |
| <p style="margin-top:1em;">By specifying the features your application requires, |
| you enable Android Market to present your application only to users whose |
| devices meet the application's feature requirements, rather than presenting it |
| to all users. </p> |
| </div> |
| </div> |
| |
| <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 <a |
| href="uses-sdk-element.html">{@code <uses-sdk>}</a> element, this element |
| allows an application to specify which device-variable features it uses. For |
| example, an application might specify that it requires a camera with auto-focus |
| capabilities.</p> |
| |
| <p>Declaring a {@code <uses-feature>} element is informational only, meaning |
| that the Android system itself does not check for matching feature support on |
| the device before installing an application. However, note that other services |
| (such as Android Market) or applications may check your application's |
| {@code <uses-feature>} declarations as part of handling or interacting |
| with your application. For this reason, it's very important that you declare all of |
| the features (from the list below) that your application uses. </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 <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> |
| <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 <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 <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 |
| <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 OpenGL ES version required by the application. The higher 16 bits |
| represent the major number and the lower 16 bits represent the minor number. For |
| example, to specify OpenGL ES version 2.0, you would set the value as |
| "0x00020000". To specify OpenGL ES 2.1, if/when such a version were made |
| available, you would set the value as "0x00020001". |
| |
| <p>An application should specify at most one <code>android:glEsVersion</code> |
| attribute in its manifest. If it specifies more than one, the |
| <code>android:glEsVersion</code> with the numerically highest value is used and |
| any other values are ignored.</p> |
| |
| <p>If an application does not specify an <code>android:glEsVersion</code> |
| attribute, then it is assumed that the application requires only OpenGL ES 1.0, |
| which is supported by all Android-powered devices.</p> |
| |
| <p>An application can assume that if a platform supports a given OpenGL ES |
| version, it also supports all numerically lower OpenGL ES versions. Therefore, |
| an application that requires both OpenGL ES 1.0 and OpenGL ES 2.0 must specify |
| that it requires OpenGL ES 2.0.</p> |
| |
| <p>An application that can work with any of several OpenGL ES versions should |
| only specify the numerically lowest version of OpenGL ES that it requires. (It |
| can check at run-time whether a higher level of OpenGL ES is available.)</p> |
| </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>Attribute 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 <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 <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—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 <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 <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>Live Wallpaper</td> |
| <td>{@code android.software.live_wallpaper}</td> |
| <td>The application uses or provides Live Wallpapers and should be installed only on devices that support Live Wallpapers. |
| </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 <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 <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> |