Blog Archives

Accessing the frontal camera in Galaxy Tab (Android 2.2)

This is just a quick tip for those of you trying to access the frontal camera in Android 2.2. Probably, you’d found out that it’s not so easy as it should be. The Android 2.2 does not have any official support for frontal cameras. In fact, the Android 2.2 does not have ANY official support for more than ONE camera. So, OFFICIALLY it’s not possible to use the frontal camera of your device if it’s Android 2.2 powered. What a shame… seriously… this is a quite basic feature… shouldn’t be that difficult. Fortunately, the Google fixed this in Android 2.3. But, thanks to Android fragmentation, I cannot just upgrade my system and, consequently, I’m stuck with Android 2.2. Again… what a shame… =S

After almost one week of googling, my fellow Hugo discovered a workaround for the particular case of Galaxy Tab (the device we’re using). I’m not sure if it’ll work in other Android 2.2 device… if you try it, let me know the result. So here is what you have to do:

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

The magic is done in the third line with the parameter "camera-id". I think this is self-explanatory, thus I’m finishing here. Until next post and good luck with it =).

UPDATE: it seems this won’t work with camera.takePicture

UPDATE: of course, you need to put the following in AndroidManifest.xml:

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