diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java index 32e1bf63..3ddcf32f 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java @@ -138,8 +138,8 @@ abstract class CameraController implements CameraPreview.SurfaceCallback { LOG.i("Stop immediately. Stopped. State is:", ss()); } catch (Exception e) { // Do nothing. + LOG.i("Stop immediately. Exception while stopping.", e); mState = STATE_STOPPED; - mCameraCallbacks.onError("Stop immediately. Exception while stopping.", e); } } diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java index 2ddfd678..7e56dc54 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java @@ -1569,10 +1569,15 @@ public class CameraView extends FrameLayout { LOG.e(message, cause); // redirect - CameraException cameraException = new CameraException(message, cause); - for (CameraListener listener : mListeners) { - listener.onError(cameraException); - } + final CameraException cameraException = new CameraException(message, cause); + mUiHandler.post(new Runnable() { + @Override + public void run() { + for (CameraListener listener : mListeners) { + listener.onError(cameraException); + } + } + }); } }