Android examples for android.hardware:Front Camera
find Front Facing Camera
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;/*from w w w . j av a 2s .co m*/ break; } } return cameraId; } }