Example usage for android.hardware Camera setPreviewCallback

List of usage examples for android.hardware Camera setPreviewCallback

Introduction

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

Prototype

public final void setPreviewCallback(PreviewCallback cb) 

Source Link

Document

Installs a callback to be invoked for every preview frame in addition to displaying them on the screen.

Usage

From source file:Main.java

/** Sets the given callback object on the given camera. Calls setPreviewCallbackWithBuffer if the Android API supports it,
 * otherwise calls setPreviewCallback./*  w  w  w  . java2s.  c  o  m*/
 */
public static boolean setPreviewCallbackWithBuffer(Camera camera, Camera.PreviewCallback callback) {
    if (setPreviewCallbackWithBufferMethod == null) {
        camera.setPreviewCallback(callback);
        return false;
    }
    try {
        setPreviewCallbackWithBufferMethod.invoke(camera, callback);
        return true;
    } catch (Exception ignored) {
        camera.setPreviewCallback(callback);
        return false;
    }
}

From source file:com.nekomeshi312.whiteboardcorrection.WhiteBoardCorrectionActivity.java

private void takePic(Camera c) throws RuntimeException {
    if (mShutterStatus == SHUTTER_STATUS_TAKEPIC && mFocusStatus == FOCUS_STATUS_FOCUS_OK) {
        mShutterStatus = SHUTTER_STATUS_TAKEN;
        c.setPreviewCallback(null);
        c.takePicture(null, null, null, this);
    }//from  w w w.j  av a2 s .  com
}