get Back Camera Number - Android android.hardware

Android examples for android.hardware:Back Camera

Description

get Back Camera Number

Demo Code

import android.hardware.Camera;

public class Main{


    public static int getBackCameraNumber() {
        for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
            Camera.CameraInfo info = new Camera.CameraInfo();
            Camera.getCameraInfo(i, info);
            if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
                return i;
            }/*from ww w  .j  a  va 2 s  .  com*/
        }
        return 0;
    }

}

Related Tutorials