Example usage for android.hardware.camera2 CameraMetadata FLASH_MODE_OFF

List of usage examples for android.hardware.camera2 CameraMetadata FLASH_MODE_OFF

Introduction

In this page you can find the example usage for android.hardware.camera2 CameraMetadata FLASH_MODE_OFF.

Prototype

int FLASH_MODE_OFF

To view the source code for android.hardware.camera2 CameraMetadata FLASH_MODE_OFF.

Click Source Link

Document

Do not fire the flash for this capture.

Usage

From source file:com.oddsix.nutripro.fragments.Camera2Fragment.java

public void setFlash(int flashMode) {
    switch (flashMode) {
    case FLASH_AUTO:
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
        break;/*from  www.java 2s.c o  m*/
    case FLASH_OFF:
        mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_OFF);
        break;
    case FLASH_ON:
        mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_SINGLE);
        break;
    }
    try {
        // Reset the auto-focus trigger
        mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.mysampleapp.camera.Camera2BasicFragment.java

/**
 * Unlock the focus. This method should be called when still image capture sequence is
 * finished.//w w  w.  ja va2  s.c om
 */
private void unlockFocus() {
    try {
        // Reset the auto-focus trigger
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.FLASH_MODE_OFF);
        setAutoFlash(mPreviewRequestBuilder);
        mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler);
        // After this, the camera will go back to the normal state of preview.
        mState = STATE_PREVIEW;
        mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}