From 2cf4b60f0f1fb6181d0a0e5f6eee94803173364f Mon Sep 17 00:00:00 2001 From: Ralf Kistner Date: Mon, 20 Mar 2017 13:18:24 +0200 Subject: [PATCH] Handle getParameters() failure in onPreviewFrame(). --- .../journeyapps/barcodescanner/camera/CameraManager.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/zxing-android-embedded/src/com/journeyapps/barcodescanner/camera/CameraManager.java b/zxing-android-embedded/src/com/journeyapps/barcodescanner/camera/CameraManager.java index 443421024..221496598 100755 --- a/zxing-android-embedded/src/com/journeyapps/barcodescanner/camera/CameraManager.java +++ b/zxing-android-embedded/src/com/journeyapps/barcodescanner/camera/CameraManager.java @@ -96,12 +96,14 @@ public void onPreviewFrame(byte[] data, Camera camera) { Size cameraResolution = resolution; PreviewCallback callback = this.callback; if (cameraResolution != null && callback != null) { - int format = camera.getParameters().getPreviewFormat(); try { + int format = camera.getParameters().getPreviewFormat(); SourceData source = new SourceData(data, cameraResolution.width, cameraResolution.height, format, getCameraRotation()); callback.onPreview(source); - } catch (IllegalArgumentException e) { - // Image data does not match the resolution + } catch (RuntimeException e) { + // Could be: + // java.lang.RuntimeException: getParameters failed (empty parameters) + // IllegalArgumentException: Image data does not match the resolution Log.e(TAG, "Camera preview failed", e); callback.onPreviewError(e); }