diff --git a/android/src/main/java/com/mrousavy/camera/CameraView+TakeSnapshot.kt b/android/src/main/java/com/mrousavy/camera/CameraView+TakeSnapshot.kt index 461824a..3f3299b 100644 --- a/android/src/main/java/com/mrousavy/camera/CameraView+TakeSnapshot.kt +++ b/android/src/main/java/com/mrousavy/camera/CameraView+TakeSnapshot.kt @@ -22,7 +22,9 @@ suspend fun CameraView.takeSnapshot(options: ReadableMap): WritableMap = corouti camera.cameraControl.enableTorch(true).await() } - val bitmap = this@takeSnapshot.previewView.bitmap ?: throw CameraNotReadyError() + val bitmap = withContext(coroutineScope.coroutineContext) { + previewView.bitmap ?: throw CameraNotReadyError() + } val quality = if (options.hasKey("quality")) options.getInt("quality") else 100