Showing results for 
Search instead for 
Did you mean: 

How To Access The Front Camera On The Cisco DX650

This blog was generated from CDN blog

Created by: James Catalano on 25-03-2013 10:45:01 AM
Like many popular 7-inch Android devices on the market today, the  Cisco Desktop Collaboration Experience DX650 (or simply the Cisco DX650) has only a front-facing camera. This camera on the DX650 will primarily be used for video conferencing and other face-to-face collaboration, but it is obviously, because of the nature of Android, open to being accessed by developers through provided APIs. The API used to access the front-facing camera on the DX650 is the standard Android camera API. This means that the methods used to access the front camera on the DX650 is similar to (OK,  the same as) the way it is done on every other Android device with a front camera on the market.

A front-facing camera isn't something that has been around since the beginning of Android. Neither the early Android devices nor the original iPhone for that matter had cameras on the front of the device, only on the rear for more traditional photo taking situations. It wasn't until Gingerbread (Android API level 9) that front-facing cameras were officially supported on Android. This means that Android's default implemenations for cameras on their devices revolved around back-facing cameras. Calling the default method will open a device's default back-facing camera. If a device doesn't have a back-facing camera, this method returns null, even if the device DOES have a front-facing camera. In order to open and use an Android device's front-facing camera (yes, this includes the DX650) you have to call a different version of the Android Camera open() method that takes a parameter referring to the "id" of the camera.

But how do I know this "id", you ask? Well, the camera sample application included with the DX650 Add-on (available on this site) provides an example on how to find and open the DX650's front-facing camera. To sum it up in words, you can iterate through the device's cameras, check to see if they are front or rear facing, and select the first front-facing one you come across (you probably won't come across too many devices with multiple front-facing cameras). To sum it up in code, the following code snippet, which is also present in the sample app, shows how:

 1Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
 2int cameraCount = Camera.getNumberOfCameras();
 3for (int i=0; i<cameraCount; i++) {
 4    Camera.getCameraInfo(i, cameraInfo);
 5    if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT && camera == null) {
 6        try {
 7            camera =;
 8        } catch (RuntimeException e) {
 9            Log.e(LOG_TAG, "Camera failed to open", e);
10        }
11    }

So now you know how to open the front camera on the DX650, but where do you put this code in your project? In our sample, we put this code in our sample Activity's onResume() method. While this is fine for basic implementations (like our sample) and facilitates code reuse, Android recommends that you open the camera on a separate thread launched from onCreate(). The Android Developer site's lesson on "Controlling the Camera" talks about this issue as well as others around controlling the camera. Also, the Android Developers' Camera overview gives a step-by-step walkthough of what your code needs to do to take a picture or record a video using the Android Camera APIs. With the information from these links and the sample application included in the DX650 Add-on, you should have no problem enabling the DX650's camera in your enterprise application.
CreatePlease to create content
Content for Community-Ad
August's Community Spotlight Awards