Skip to content
Snippets Groups Projects
Commit 8dd9b583 authored by akwizgran's avatar akwizgran
Browse files

Don't request focus modes that aren't supported by the camera.

parent 2b918f0f
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,11 @@ AutoFocusCallback {
this.previewConsumer = previewConsumer;
setDisplayOrientation(rotationDegrees);
Parameters params = camera.getParameters();
params.setFocusMode(macro ? FOCUS_MODE_MACRO : FOCUS_MODE_AUTO);
List<String> modes = params.getSupportedFocusModes();
if(macro && modes.contains(FOCUS_MODE_MACRO))
params.setFocusMode(FOCUS_MODE_MACRO);
else if(modes.contains(FOCUS_MODE_AUTO))
params.setFocusMode(FOCUS_MODE_AUTO);
camera.setParameters(params);
SurfaceHolder holder = getHolder();
holder.addCallback(this);
......@@ -68,6 +72,7 @@ AutoFocusCallback {
private void stopPreview() {
try {
previewConsumer.stop();
camera.cancelAutoFocus();
camera.stopPreview();
} catch(Exception e) {
Log.e(TAG, "Error stopping camera preview", e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment