select Camera by facing - Android Camera

Android examples for Camera:Camera Facing

Description

select Camera by facing

Demo Code


import android.hardware.Camera;

public class Main{
    public static SelectedCamera selectCamera(int facing) {
        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
        int cameras = Camera.getNumberOfCameras();
        for (int i = 0; i < cameras; i++) {
            Camera.getCameraInfo(i, cameraInfo);
            if (cameraInfo.facing == facing) {
                return new SelectedCamera(cameraInfo, i);
            }/*w w w.jav  a2 s  .  co  m*/
        }

        return null;
    }
}

Related Tutorials