How to autofocus Android camera automatically?

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);

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)