Java tutorial
//package com.java2s; import android.hardware.Camera; public class Main { public static int getFrontCameraID() { int camerasCnt = getAvailableCamerasCount(); int defaultCameraID = -1; Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); for (int i = 0; i < camerasCnt; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { defaultCameraID = i; } } return defaultCameraID; } public static int getAvailableCamerasCount() { return Camera.getNumberOfCameras(); } }