camera Is In Use - Android android.hardware

Android examples for android.hardware:Camera State

Description

camera 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 cameraIsInUse(int cameraId) {
        Camera camera = null;//from www . j a  v a2 s  . com

        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