Example usage for android.hardware Camera open

List of usage examples for android.hardware Camera open

Introduction

In this page you can find the example usage for android.hardware Camera open.

Prototype

public static Camera open() 

Source Link

Document

Creates a new Camera object to access the first back-facing camera on the device.

Usage

From source file:Main.java

public static Camera getCameraInstance() {
    Camera c = null;/*from   w  w w.  j  a  v  a  2s .co  m*/
    try {
        c = Camera.open(); // attempt to get a Camera instance
    } catch (Exception e) {
        // Camera is not available (in use or does not exist)
    }
    return c; // returns null if camera is unavailable
}

From source file:Main.java

private static Camera getCameraInstance() {
    if (null == camera) {
        camera = Camera.open();
    }
    return camera;
}

From source file:Main.java

public static Camera makeCameraAvailable() {
    releaseCamera();
    camera = Camera.open();
    return camera;
}

From source file:Main.java

public static boolean isBackCameraAvailable() {
    try {/* www  . j  a  va2  s .  c  o  m*/
        Camera camera = Camera.open();
        if (null != camera) {
            camera.release();
            camera = null;
            return true;
        }
    } catch (Exception e) {
    }
    return false;
}

From source file:Main.java

public static Camera getCameraInstance() throws Exception {
    if (camera == null) {
        camera = Camera.open(); // attempt to get a Camera instance
    }/*from www .ja va 2  s. co  m*/
    return camera; // returns null if camera is unavailable
}

From source file:Main.java

public static Camera getCameraInstance() {
    Camera c = null;//from w  w  w . j a  v a 2s . c om

    try {
        c = Camera.open();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return c;
}

From source file:Main.java

public static void close(Context context) {
    Camera cam = Camera.open();
    cam.stopPreview();
    cam.release();

}

From source file:Main.java

public static Camera getCameraInstance() {
    Camera camera = null;//from   www.  j a  v a2  s .c  om
    try {
        // attempt to get a Camera instance
        camera = Camera.open();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return camera;
}

From source file:Main.java

/** A safe way to get an instance of the Camera object. */
public static Camera getCameraInstance() {
    Camera c = null;/*from   ww  w  .j a  va2s. c om*/
    try {
        c = Camera.open(); // attempt to get a Camera instance
    } catch (Exception e) {
        // Camera is not available (in use or does not exist)
    }
    return c; // returns null if camera is unavailable
}

From source file:Main.java

/** A safe way to get an instance of the Camera object. */
public static Camera getCameraInstance() {
    Camera c = null;//from w w  w. j a  v  a 2s . c om
    try {
        c = Camera.open(); // attempt to get a Camera instance
        c.setDisplayOrientation(90);
    } catch (Exception e) {
        // Camera is not available (in use or does not exist)
    }
    return c; // returns null if camera is unavailable
}