camera Facing Front Is In Use - Android android.hardware

Android examples for android.hardware:Front Camera

Description

camera Facing Front Is In Use

Demo Code

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.hardware.Camera;

public class Main{

    public static Camera cameraFacingFrontIsInUse() {
        return cameraIsInUse(Camera.CameraInfo.CAMERA_FACING_FRONT);
    }//from www .j  ava  2s  .c  o m
    public static Camera cameraIsInUse(int cameraId) {
        Camera camera = null;

        try {
            do {
                if (cameraId < 0 || cameraId >= Camera.getNumberOfCameras()) {
                    break;
                }
                camera = Camera.open(cameraId); // attempt to get a Camera instance
            } while (false);

        } catch (Exception e) {
            // Camera is not available (in use or does not exist)
        }

        return camera;// returns null if camera is unavailable
    }

}

Related Tutorials