Here you can find the source of getCameraId(int facing)
public static int getCameraId(int facing)
//package com.java2s; import android.hardware.Camera; import android.hardware.Camera.CameraInfo; public class Main { public static int getCameraId(int facing) { int cameraId = -1; // Search for the front facing camera int numberOfCameras = Camera.getNumberOfCameras(); for (int i = 0; i < numberOfCameras; i++) { CameraInfo info = new CameraInfo(); Camera.getCameraInfo(i, info); if (info.facing == facing) { cameraId = i;/*from w w w.j a va 2s.c om*/ break; } } return cameraId; } }