Camera for Android: front or rear camera required

My application needs a camera to work. However, it does not matter if it is a rear or front camera.

Now I have this in my manifest:

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

To claim a front camera, I know that I could also add this:

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

But I would like to support all devices that have a camera. Is there any way to do this?

For example, I want to support the Nexus 7, which has only a front camera. But I also want to support devices with only a rear camera.

According to some research I have done, for example:

http://code.google.com/p/android/issues/detail?id=35166

It seems to be impossible.

I think one way to solve this problem would be to make 2 separate APKs, one with android.hardware.camera and one with android.hardware.camera.front and download both on Google Play using Multi-APK support . I have not tested it yet.

Has anyone found a recommended way to support all devices with a front camera, a rear camera, or both, but not devices without any cameras?

+7
source share
3 answers

A few thoughts (no definite answer):

a) I believe that you are right that there is currently no good way to require a camera in the APK.

b) If you want, you can remove the use function and check the camera at runtime. This will degrade the user's work, but will work.

c) You can use use required = "false" (http://developer.android.com/guide/topics/manifest/uses-feature-element.html). We hope that in the Google Market priorities will be implemented using this flag.

c) Side note. As I know, most Android devices have a camera. So, if you go with solution b) or c) only a very small user base will notice the difference

+2
source

This has changed since it was answered, now you can add uses-feature to the manifest, which requires any camera:

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

Just add my 2 cents to this discussion:

I got the same result as @Cat described in a comment to Juan Cortes.

The way I tested this was using aapt (testing instructions found at http://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions-features ) and finding explicit or implicit camera requirements:

No <uses-feature> , but camera permission required: enter image description here Observe uses-implied-feature

Using only <uses-feature android:name="android.hardware.camera.any" android:required="false" /> : enter image description here Still implying that the application ALWAYS needs a camera.

both <uses-feature android:name="android.hardware.camera.any" android:required="false" /><uses-feature android:name="android.hardware.camera" android:required="false" /> defined: enter image description here No more implied features.

Hope this helps someone profile their own application.

0
source

All Articles