Android examples for android.hardware:Front Camera
find First Front Facing Camera
import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageManager; import android.hardware.Camera; import android.hardware.Camera; public class Main{ public static int findFirstFrontFacingCamera() { int foundId = -1; int numCameras = Camera.getNumberOfCameras(); for (int cameraId = 0; cameraId < numCameras; cameraId++) { CameraInfo info = new CameraInfo(); Camera.getCameraInfo(cameraId, info); if (info.facing == CameraInfo.CAMERA_FACING_FRONT) { foundId = cameraId;/*from ww w. j a va 2 s . c o m*/ break; } } return foundId; } }