Android examples for android.hardware:Front Camera
get Front Camera Id
import android.content.Context; import android.graphics.Point; import android.hardware.Camera; import android.util.Log; import android.view.Surface; import android.view.WindowManager; import java.util.List; public class Main{ private static int frontCameraId = -1; public static int getFrontCameraId() { if (frontCameraId == -1) { Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); for (int i = 0; i < getCameraNumber(); i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { frontCameraId = i;/*from ww w .j a va 2 s . com*/ break; } } } return frontCameraId; } public static int getCameraNumber() { if (cameraNumber == -1) { cameraNumber = Camera.getNumberOfCameras(); } return cameraNumber; } public static Camera.CameraInfo getCameraInfo(int id) { if (id >= 0 && id < getCameraNumber()) { Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); Camera.getCameraInfo(id, cameraInfo); return cameraInfo; } return null; } }