From df93704676b11e4dd525ae57ff6415bbba09399f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Eisfeld?= Date: Mon, 11 Sep 2017 09:44:52 +0200 Subject: [PATCH] Fixed NullPointerExceptions (in particular related to headset plug-in) --- .../augendiagnoselib/activities/CameraActivity.java | 8 +++++++- .../de/jeisfeld/augendiagnoselib/util/Camera2Handler.java | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/activities/CameraActivity.java b/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/activities/CameraActivity.java index fc9f78cb..0e332581 100644 --- a/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/activities/CameraActivity.java +++ b/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/activities/CameraActivity.java @@ -794,7 +794,13 @@ private void registerHeadsetReceiver() { mHeadsetPlugReceiver.register(this, new HeadsetPlugReceiver.HeadsetPlugHandler() { @Override public void handleHeadsetPlug(final boolean plugged) { - configureFlashlightButton(); + try { + configureFlashlightButton(); + } + catch (Exception e) { + TrackingUtil.sendException("hea1", e); + return; + } if (plugged && mCurrentFlashlightMode != FlashMode.EXT) { DialogUtil.displayConfirmationMessage(CameraActivity.this, new ConfirmDialogListener() { private static final long serialVersionUID = 1L; diff --git a/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/util/Camera2Handler.java b/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/util/Camera2Handler.java index ba0672ee..0b9f6778 100644 --- a/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/util/Camera2Handler.java +++ b/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/util/Camera2Handler.java @@ -773,7 +773,7 @@ private void unlockFocus() { mState = CameraState.STATE_PREVIEW; mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler); } - catch (CameraAccessException | IllegalStateException e) { + catch (CameraAccessException | IllegalStateException | NullPointerException e) { mCameraCallback.onCameraError("Failed to unlock focus", "unl1", e); } }