Android Camera Facing Get getFirstBackFacingCameraID()

Here you can find the source of getFirstBackFacingCameraID()

Description

get First Back Facing Camera ID

Return

the id of the first BackFacing camera

Declaration

public static int getFirstBackFacingCameraID() 

Method Source Code

//package com.java2s;

import android.hardware.Camera;

public class Main {
    /**/*from  ww w. j a  va2s  .  c om*/
     *
     * @return the id of the first BackFacing camera
     */
    public static int getFirstBackFacingCameraID() {
        int lCamId = 0;

        for (lCamId = 0; lCamId < Camera.getNumberOfCameras(); lCamId++) {
            Camera.CameraInfo lCameraInfo = new Camera.CameraInfo();
            Camera.getCameraInfo(lCamId, lCameraInfo);
            if (lCameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK)
                return lCamId;

        }
        return 0;
    }
}