Here you can find the source of getBackId()
static public int getBackId() throws Exception
//package com.java2s; import android.hardware.Camera; import android.hardware.Camera.CameraInfo; public class Main { static public int getBackId() throws Exception { int numberOfCameras = Camera.getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { return i; }/*from w ww . j a v a 2s. co m*/ } throw new Exception(); } }