I want to autofocus Android camera as soon as camera holds still. Im looking for tutorials or samples how to do it or at least small sample that shows what classes I can use
Try to use Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO
or Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE
.
See below:
Camera.Parameters params = camera.getParameters();
if (params.getSupportedFocusModes().contains(
Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
}
camera.setParameters(params);
It's important to test whether the phone is supporting your chosen mode before attempting to use it, otherwise setParameters()
will throw a runtime exception.
(Edit code now working properly)