public void pause() {
        // This must be safe to call multiple times.
        Util.validateMainThread();
        Log.d(TAG, "pause()");

        openedOrientation = -1;
        if (cameraInstance != null) {
            cameraInstance.close();
            cameraInstance = null;
            previewActive = false;
        } else {
            stateHandler.sendEmptyMessage(R.id.zxing_camera_closed);
        }
        if (currentSurfaceSize == null && surfaceView != null) {
            SurfaceHolder surfaceHolder = surfaceView.getHolder();
            surfaceHolder.removeCallback(surfaceCallback);
        }
        if (currentSurfaceSize == null && textureView != null) {
            textureView.setSurfaceTextureListener(null);
        }

        this.containerSize = null;
        this.previewSize = null;
        this.previewFramingRect = null;
        rotationListener.stop();

        fireState.previewStopped();
    }
Pause scanning and the camera preview. Typically this should be called from the Activity's
onPause() method.

Call from UI thread only.
zxing-android-embedded/src/com/journeyapps/barcodescanner/CameraPreview.java