Java tutorial
//package com.java2s; import android.hardware.Camera; import android.util.Log; public class Main { public static final int INVALID_CAMERA_ID = -1; public static int findFrontFacingCamera() { 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_FRONT) { Log.d("CameraUtil", "Camera found"); cameraId = i; break; } } return cameraId; } }