Example usage for android.hardware Camera stopPreview

List of usage examples for android.hardware Camera stopPreview

Introduction

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

Prototype

public final void stopPreview() 

Source Link

Document

Stops capturing and drawing preview frames to the surface, and resets the camera for a future call to #startPreview() .

Usage

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 releaseCamera(Camera camera) {
    if (camera != null) {
        camera.stopPreview();
        camera.release();/* w w  w .ja v a  2 s  .  c om*/
        camera = null;
    }
    return camera;
}

From source file:Main.java

public static boolean closeFlightLight(Camera camera) {
    if (null != camera) {
        Parameters parameters = camera.getParameters();
        List<String> list = parameters.getSupportedFlashModes();
        for (String string : list) {
            if (Parameters.FLASH_MODE_OFF.equals(string)) {
                parameters.setFlashMode(string);
                camera.setParameters(parameters);
                camera.stopPreview();
                camera.release();//  w  ww  .j a v  a  2  s. co  m
                camera = null;
                return true;
            }
        }
    }
    return false;
}

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

public void stopPreview() {
    // TODO Auto-generated method stub
    Log.i(LOG_TAG, "stopPreview");
    if (mCameraSetting == null)
        return;// w w  w. j av a  2  s . c  o  m
    try {
        if (mCameraSetting.getCamera() != null) {
            final Camera camera = mCameraSetting.getCamera();
            camera.setPreviewCallbackWithBuffer(null);
            mBuffer = null;
            camera.stopPreview();
            if (mWbDetect != null) {
                mWbDetect = null;
            }
            if (mLineDetector != null) {
                mLineDetector.cleanUp();
                mLineDetector = null;
            }

            if (mMatYuv != null) {
                mMatYuv.release();
                mMatYuv = null;
            }
            if (mMatRgba != null) {
                mMatRgba.release();
                mMatRgba = null;
            }
            if (mBmp != null) {
                mBmp.recycle();
                mBmp = null;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}