diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java index 39d01df2..6f40412a 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java @@ -30,12 +30,17 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera private Camera mCamera; private boolean mIsBound = false; + private boolean mDelayRunnable = false; private final int mPostFocusResetDelay = 3000; private Runnable mPostFocusResetRunnable = new Runnable() { @Override public void run() { if (!isCameraAvailable()) return; + if (mDelayRunnable) { + mDelayRunnable = false; // Delay focus further - fixes Samsung devices + return; + } mCamera.cancelAutoFocus(); Camera.Parameters params = mCamera.getParameters(); params.setFocusAreas(null); @@ -493,6 +498,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera if (mIsCapturingVideo && !mCameraOptions.isVideoSnapshotSupported()) return; mIsCapturingImage = true; + mDelayRunnable = true; // delaying focus (fixes crash on samsung) final int sensorToOutput = computeSensorToOutputOffset(); final int sensorToView = computeSensorToViewOffset(); final boolean outputMatchesView = (sensorToOutput + sensorToView + 180) % 180 == 0; @@ -805,6 +811,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera mCamera.setParameters(params); mCameraCallbacks.dispatchOnFocusStart(gesture, p); // TODO this is not guaranteed to be called... Fix. + // TODO Updated: Kind of fixed with mDelayRunnable on image capture mCamera.autoFocus(new Camera.AutoFocusCallback() { @Override public void onAutoFocus(boolean success, Camera camera) {