1

I have an app ready to go that requires that there be a rear facing camera. Obviously it has the <uses-permission android:name="android.permission.CAMERA" /> permission in the manifest but this does not rule out devices such as the Nexus 7 tablet which has only a front facing camera.

Short of going through and manually excluding the devices how can I do this?

SamRowley
  • 3,435
  • 7
  • 48
  • 77

2 Answers2

0

I only know of a programmatical answer. As this question indicates, you can use

PackageManager pm = context.getPackageManager();
return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);

This returns false if the device has no back facing camera (so false on the Nexus 7)

the flag

FEATURE_CAMERA_FRONT

will still be true instead. So you can use this test on launch of your first activity, along with a big warning in your app description.

However, I don't know of a way to use the manifest to exclude the devices on this criteria, short of manually excluding devices.

Edit: another question linked as related points out this uses-feature flag for the manifest:

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

According to the docs:

The application uses the device's camera. If the device supports multiple cameras, the application uses the camera that facing away from the screen.

So it's a bit ambiguous for front-facing only devices.

Community
  • 1
  • 1
gatnowurry
  • 344
  • 1
  • 7
0

You can Use uses-feature tag given inandroid. You have to declare this tag in manifest file. It automatically filter the device based on given condtion. Just use this uses-feature tag in manifest like this:

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

For more detail follow the following links:- Android Uses Premission

SAURABH_12
  • 2,262
  • 1
  • 19
  • 19
  • Even if you do not use android:required="true", the Google Play system assumes that this is a required property and filters on that basis. – Ethen Hunt Aug 18 '14 at 20:21