get Front Camera Number - Android Camera

Android examples for Camera:Front Camera

Description

get Front Camera Number

Demo Code


//package com.java2s;
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 ww  w. jav a  2 s  .  co  m
        }
        return 0;
    }
}

Related Tutorials