3

My question is related to camera. When an application needs to use the system camera, we create an intent with ACTION_IMAGE_CAPTURE action and add a permission like this in the manifest file.

<uses-permission android:name="android.permission.CAMERA"/>

But besides that, there is one such

<uses-feature android:name="android.hardware.camera"/>

What is it for? I read that if this line is written, then if the phone does not have a camera the application will not install. Is it true? And besides this, why do we need this?

And for what the line <uses-feature/> is generally responsible in manifest file?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Hayk Mkrtchyan
  • 2,835
  • 3
  • 19
  • 61
  • 2
    Your questions seem to be covered in [the documentation for ``](https://developer.android.com/guide/topics/manifest/uses-feature-element). Also note that you do not need `android.permission.CAMERA` if you are using `ACTION_IMAGE_CAPTURE`. – CommonsWare May 28 '19 at 13:26

5 Answers5

4
<uses-feature android:name="android.hardware.camera"/>

above line will use to check the device have camera hardware.

When you upload an app on play store they will filter your app based on the feature for the specific device,

if any device will search your app on play store and that device doesn't have camera hardware then they will not be allowed to install an app on that device.

but if your requirement is to force download the app if the device doesn't have camara hardware the you can use : <uses-feature android:name="android.hardware.camera" android:required="false"/> the android:required = "false" will allow you to install

hope you understand

Mitesh Machhoya
  • 404
  • 2
  • 8
3

Google documentation for <uses-feature> itself clearly states:

Google Play uses the <uses-feature> elements declared in your app manifest to filter your app from devices that do not meet its hardware and software feature requirements.

By specifying the features that your application requires, you enable Google Play to present your application only to users whose devices meet the application's feature requirements, rather than presenting it to all users.

Some permissions in Android are connected to some hardware/software features of a device, like CAMERA. Since every Android device in the market differs in its hardware and software configuration, there's a greater possibility that some feature that you're trying to add in your app doesn't support all Android Devices. If you try to use the camera in a camera-less device (a superficial assumption), then your app will not behave as you expect.

In short, if you want your app to only be available for the set of devices having that particular capability, then you can add <uses-feature> tag inside the manifest with the desired capability. This is just for filtering apps in Play Store based on device configuration and support. You can define zero or more <uses-feature> capabilities based on your need.

Note: If you don't want your app to get filtered out just for the sake of a feature that doesn't impact the overall user experience of the app, you can smartly disable the particular feature if it's not available in your app.

For that, you have to write

<uses-feature android:name="YOUR_NON_COMPULSORY_FEATURE" android:required="false" />

For example, if your app uses CAMERA feature, but your app is not dependent on that feature, you can disable just the CAMERA feature to provide a non-buggy user experience.

Maulik Hirani
  • 1,673
  • 1
  • 12
  • 19
1

This is very important part. Let suppose your application uses a particular hard ware and that is essential for your app that hardware must be available on a device to use your application. If that is defined, your app will be filtered out for those devices that have that specific hard ware.

NOTE: As it is well documented over Google Developer site

**Google Play uses the elements declared in your app manifest to filter your app from devices that do not meet its hardware and software feature requirements.

By specifying the features that your application requires, you enable Google Play to present your application only to users whose devices meet the application's feature requirements, rather than presenting it to all users.**

Refer this link for further reference guide

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
Abdul Waheed
  • 4,540
  • 6
  • 35
  • 58
1

<uses-feature/> is there to guide Google play store to filter out this application from devices which do not have Camera hardware.

Vishal Pawar
  • 4,324
  • 4
  • 28
  • 54
1

As a developer - lets ask this Question to ourself with respect to your app.

What will user do with my app whose phone does not have Camera?

If the answer to Above is "Not much" - then what is the point allowing user to install your app on phone if user can't do much with it? It is waste of time & Internet bandwidth for the user.

Also if user is really frustrated by eventually learning that this app is not much of use, they may RATE your app poorly on Play Store.

Hence its there is <uses-feature/> option to protect both developers & users from above scenario.

AADProgramming
  • 6,077
  • 11
  • 38
  • 58