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" />

Posted on April 30, 2011, in Android and tagged , , , . Bookmark the permalink. 3 Comments.

  1. Hey there,

    since nobody seems to know if there will be a port of Gingerbread for the Galaxy Tab, I was wondering if you had any further success accessing the FCC using your workaround. In my case, directly accessing the FFC’s image would be what I want to achieve; do you think that’s possible…? :-/

    And can you please also provide information on which line to add to AndroidManifest.xml?

    Thank you very much, best wishes from here! :-)

  2. Rafael Barreto

    Hi steve,

    you can access it. In fact, I’m using it to put a face detector in the Galaxy Tab. Do it the usual way, i.e., implementing Camera.PreviewCallback. All you need to know is here:

    http://developer.android.com/reference/android/hardware/Camera.html

    and here:

    http://developer.android.com/reference/android/hardware/Camera.PreviewCallback.html

    If you are new to Android, it’s not that easy to understand at first because there’s no sample. But there’s a lot of stuff in the Web anyway. In a quick search, I found this:

    http://p2p.wrox.com/book-professional-android-application-development-isbn-978-0-470-34471-2/72528-article-using-android-camera.html

    It’s not complete, but maybe it can help.

    To use the frontal camera, the only change you have to do is that described in the post.

    Hope it helps… =)

    NOTE: Regarding the AndroidManifest.xml… fixed! The WordPress editor has problems with “less than” and “greater than” signs… thanks for point it out…

  3. Awesome, this made my day, thank you!! :-)

Leave a comment