From ff4c716e46dd3dbfb3bdd2dd74f44d913c7d3c3d Mon Sep 17 00:00:00 2001 From: TJ Woon Date: Fri, 27 Feb 2015 18:56:31 +0800 Subject: [PATCH] Re-added Paolo's Android autofocus crash fix (see 633b5f7) --- android/ZBarScannerActivity.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/ZBarScannerActivity.java b/android/ZBarScannerActivity.java index 1cbc535..d76c90d 100644 --- a/android/ZBarScannerActivity.java +++ b/android/ZBarScannerActivity.java @@ -238,7 +238,11 @@ implements SurfaceHolder.Callback { private AutoFocusCallback autoFocusCb = new AutoFocusCallback() { public void onAutoFocus(boolean success, Camera camera) { - autoFocusHandler.postDelayed(doAutoFocus, autoFocusInterval); + // some devices crash without this try/catch and cancelAutoFocus()... (#9) + try { + camera.cancelAutoFocus(); + autoFocusHandler.postDelayed(doAutoFocus, autoFocusInterval); + } catch (Exception e) {} } };