get Face Camera Index - Android Camera

Android examples for Camera:Camera Attribute

Description

get Face Camera Index

Demo Code


//package com.java2s;

import android.hardware.Camera;

public class Main {

    public static int getFaceCameraIndex() {
        int result = -1;
        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
        int cameraCount = Camera.getNumberOfCameras();
        for (int i = 0; i < cameraCount; i++) {
            Camera.getCameraInfo(i, cameraInfo);
            if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
                result = 1;/*  ww  w.j  av a 2 s  . co  m*/
                break;
            }
        }
        return result;
    }
}

Related Tutorials