Samsung Galaxy S: How to determine the presence of a front camera?

I know that we can access the front camera on Gingerbread Galaxy S devices by setting the "camera-id"Camera parameter :

Camera cam = Camera.open();
Camera.Parameters params = cam.getParameters();
params.set("camera-id", 2);

The problem is that not all Galaxy devices have a front camera. These devices have a parameter "camera-id", and it allows me to set it to 2 (front). How I found the only way to determine the presence / absence of FFC - is to see if the startPreview()throws when "camera-id"equal to 2. This is kind of an awkward solution, especially when I'm trying to support multiple devices.

Has anyone found a way to request the number of cameras on a 2.1 or 2.2 Galaxy S, or at least determine the presence of a front camera?

Thank!

+5
1

, AndroidManifest.xml :

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

, PackageManager :

PackageManager.hasSystemFeature(PackageManager. FEATURE_CAMERA_FRONT);
+2

All Articles