diff --git a/android/src/com/google/zxing/client/android/CaptureActivity.java b/android/src/com/google/zxing/client/android/CaptureActivity.java index e7ebeef1a..ffbccdbf4 100755 --- a/android/src/com/google/zxing/client/android/CaptureActivity.java +++ b/android/src/com/google/zxing/client/android/CaptureActivity.java @@ -735,6 +735,10 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal if (surfaceHolder == null) { throw new IllegalStateException("No SurfaceHolder provided"); } + if (cameraManager.isOpen()) { + Log.w(TAG, "initCamera() while already open -- late SurfaceView callback?"); + return; + } try { cameraManager.openDriver(surfaceHolder); // Creating the handler starts the preview, which can also throw a RuntimeException. diff --git a/android/src/com/google/zxing/client/android/camera/CameraManager.java b/android/src/com/google/zxing/client/android/camera/CameraManager.java index 072cbf5cd..3a5737426 100755 --- a/android/src/com/google/zxing/client/android/camera/CameraManager.java +++ b/android/src/com/google/zxing/client/android/camera/CameraManager.java @@ -94,6 +94,10 @@ public final class CameraManager { configManager.setDesiredCameraParameters(theCamera); } + public synchronized boolean isOpen() { + return camera != null; + } + /** * Closes the camera driver if still in use. */ @@ -136,7 +140,7 @@ public final class CameraManager { } /** - * Convenience method for {@link com.srowen.bs.android.CaptureActivity} + * Convenience method for {@link com.google.zxing.client.android.CaptureActivity} */ public synchronized void setTorch(boolean newSetting) { if (camera != null) {