Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Camera: require frontal OR rear camera

My app needs a Camera to work. However, it doesn't matter if it's a rear or frontal camera.

Right now, I have this in my Manifest:

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

To require a frontal Camera, I know I could also add this:

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

But I'd like to support all devices that has EITHER camera. Is there anyway to do this?

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

According to some research I've made, such as:

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

It seems this is not possible.

I think one way to solve this would be to make 2 separate APKs, one with android.hardware.camera and one with android.hardware.camera.front and upload both to Google Play, using its Multiple APK Support. I haven't tested it yet, though.

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

like image 403
Jorge Cevallos Avatar asked Sep 03 '12 15:09

Jorge Cevallos


People also ask

How do I turn off the front camera on my Android?

Disable the Front Camera on an AndroidLaunch your menu and go to Settings. Scroll down and select “Apps.” Press “Camera.” Tap “Disable.” If this option is grayed out, select “Permissions” and then switch the toggle next to “Camera.”

Can I use front and rear Camera together?

Many modern Android phones have more than one camera on the front and/or the back. Some cameras work together to make your photos look better, like capturing more light with the help of a monochrome camera, or utilizing features such as the bokeh effect using additional information from a depth camera.

What is an Android Camera?

Also called a "4G camera" or "connected camera," an Android camera enables photos to be organized in folders and accepts image editing programs from the Google Play app store. See Android. One of the First In 2012, the Samsung Galaxy was one of the first Android cameras.


3 Answers

Several thoughts (no definite answer):

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

b) If you want, you can remove uses-feature and check for a camera in runtime. It will make user experience worse, but it will work.

c) You can use use required="false" (http://developer.android.com/guide/topics/manifest/uses-feature-element.html). Hopefully, Google Market prioritize applications using this flag.

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

like image 79
Victor Ronin Avatar answered Nov 01 '22 20:11

Victor Ronin


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

<uses-feature android:name="android.hardware.camera.any" android:required="true" />
like image 2
Juan Cortés Avatar answered Nov 01 '22 19:11

Juan Cortés


Just to add my 2 cents to this discussion:

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

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

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

Using only <uses-feature android:name="android.hardware.camera.any" android:required="false" />: enter image description here Still implying that the app 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 somebody profile their own app.

like image 1
Janis Peisenieks Avatar answered Nov 01 '22 21:11

Janis Peisenieks