Need to know about uses-feature in android?

2019-05-14 08:32发布

问题:

'uses-feature' is used in following way:

  <uses-feature
  android:name="string"
  android:required=["true" | "false"]
  android:glEsVersion="integer" />

What is the use of 'android:required' and 'android:glEsVersion'?

回答1:

required is used to show that the feature the app uses is essential to the application; without that feature the app would be useless or wouldn't work. If your app uses gps, for example, as a nice-to-have feature but it isn't absolutely necessary, you could set required to false. This way, users with devices that don't have devices with gps can still download your app from the Play Store—which they otherwise couldn't.

glEsVersion is necessary only if the feature requires OpenGL ES. In that case you might want to specify at least one version to be used in the context.


Or as the developer guidelines state:

required The element offers a required attribute that lets you specify whether your application requires and cannot function without the declared feature, or whether it prefers to have the feature but can function without it. (Android Dev Guidelines)

glEsVersion For some features, there may exist a specific attribute that allows you to define a version of the feature, such as the version of Open GL used (declared with glEsVersion). […] An application should specify at most one android:glEsVersion attribute in its manifest. If it specifies more than one, the android:glEsVersion with the numerically highest value is used and any other values are ignored. If an application does not specify an android:glEsVersion attribute, then it is assumed that the application requires only OpenGL ES 1.0, which is supported by all Android-powered devices. (Android Dev Guidelines)

You can read more about <uses-feature> in the Android Developer Guidelines



回答2:

android:required is useful when every device not support hardware or feature which your app needs.

Example : My app is useful for backup purpose of SMS,contact,calllog,apk etc. But some tablets doesn't has sim card then android:required="false" work for me if that app run on that device.

android:glEsVersion 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", or to specify OpenGL ES 3.0, you would set the value as "0x00030000".



回答3:

As described in android developer.android:

The <uses-feature> lets you specify whether your application requires and cannot function without the declared feature.

The android:glEsVersion The OpenGL ES version required by the application.