get Has Rear Camera - Android Camera

Android examples for Camera:Camera Attribute

Description

get Has Rear Camera

Demo Code


//package com.java2s;

import android.hardware.Camera;
import android.os.Build;

public class Main {
    private static boolean getHasRearCamera() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
            int numberOfCameras = Camera.getNumberOfCameras();

            for (int i = 0; i < numberOfCameras; i++) {
                Camera.getCameraInfo(i, cameraInfo);

                if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
                    return true;
                }//from  w  w  w. j  av a  2 s.  com
            }
        }
        return false;
    }
}

Related Tutorials