I do it a little differently .. maybe this will help you!
params = getCamera().getParameters(); ... //Check if device supports torch mode, If YES then enable List<String> supportedFlashModes = params.getSupportedFlashModes(); if (supportedFlashModes != null && supportedFlashModes.contains(Parameters.FLASH_MODE_TORCH)){ params.setFlashMode(Parameters.FLASH_MODE_TORCH); torchModeOn = true; } ... getCamera().setParameters(params);
In comparison, I use Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE and NOT using setFocusAreas, setMeteringArea, setAutoWhiteBalanceLock, setWhiteBalance or setAutoExposureLock.
After looking at the code, I tried to turn on each of them individually to see if this would affect my photos, and you're out of luck. (My app also requires large-scale snapshots.
Options. FOCUS_MODE_MACRO did not work for me at all on any of the devices with which I tried it.
EDIT:
Here is the order in which I set up the camera if it helps ...
setCameraDisplayRotation(); params = getCamera().getParameters(); setFocusMode(); //Check if device supports torch mode, If you YES then set on List<String> supportedFlashModes = params.getSupportedFlashModes(); if (supportedFlashModes != null && supportedFlashModes.contains(Parameters.FLASH_MODE_TORCH)){ params.setFlashMode(Parameters.FLASH_MODE_TORCH); torchModeOn = true; } setImageResolution(); getCamera().setParameters(params); // update params before preview.setCamera preview.setCamera(getCamera()); //... some custom code for determining the current screens available space for the preview params.setPreviewSize(size.width, size.height); if(setHiddenParameter(params, "zsl-values", "zsl", "on")){ setUsingZsl(true); }; getCamera().setParameters(params); //update params after preview init
source share