Android examples for android.hardware:Back Camera
find Back Facing Camera
import android.hardware.Camera; import android.util.Log; public class Main{ public static final int INVALID_CAMERA_ID = -1; public static int findBackFacingCamera() { int cameraId = INVALID_CAMERA_ID; // Search for the front facing camera int numberOfCameras = Camera.getNumberOfCameras(); for (int i = 0; i < numberOfCameras; i++) { Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(i, info); if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) { Log.d("CameraUtil", "Camera found"); cameraId = i;/*from w w w .jav a 2 s .c o m*/ break; } } return cameraId; } }