android; wrap call to _camera.autoFocus into try/catch

This commit is contained in:
Deividy Metheler 2017-04-05 20:52:51 -03:00 committed by Tomas Roos
parent 8024d6992f
commit 5097f95c6f
1 changed files with 11 additions and 6 deletions

View File

@ -371,12 +371,17 @@ class RCTCameraViewFinder extends TextureView implements TextureView.SurfaceText
List<String> supportedFocusModes = params.getSupportedFocusModes();
if (supportedFocusModes != null && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
_camera.autoFocus(new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(boolean b, Camera camera) {
// currently set to auto-focus on single touch
}
});
try {
_camera.autoFocus(new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(boolean b, Camera camera) {
// currently set to auto-focus on single touch
}
});
} catch (Exception e) {
// just print stack trace, we don't want to crash by autoFocus fails
e.printStackTrace();
}
}
}