Java tutorial
//package com.java2s; //License from project: GNU General Public License import android.hardware.Camera; public class Main { static final int NO_CAMERA = -101; static int getCameraId(int position) { // Find the total number of cameras available int mNumberOfCameras = Camera.getNumberOfCameras(); // Find the ID of the back-facing ("default") camera Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); for (int i = 0; i < mNumberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == position) return i; } return NO_CAMERA; } }