get Front Camera Number - Android android.hardware

Android examples for android.hardware:Front Camera

Description

get Front Camera Number

Demo Code

import android.hardware.Camera;

public class Main{

    public static int getFrontCameraNumber() {
        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_FRONT) {
                return i;
            }/*from   w ww .j av a2  s  .c o m*/
        }
        return 0;
    }

}

Related Tutorials