How to autofocus Android camera automatically?

Alexey Zakharov picture Alexey Zakharov · Mar 25, 2013 · Viewed 95k times · Source

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 to hook on such events.

Answer

lukas_wins picture lukas_wins · Apr 24, 2014

For me this worked a treat:

//set camera to continually auto-focus
Camera.Parameters params = c.getParameters();
//*EDIT*//params.setFocusMode("continuous-picture");
//It is better to use defined constraints as opposed to String, thanks to AbdelHady
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
c.setParameters(params);