The API2 camera looks weird to start with, but then you'll see that it's pretty simple.
The best answer for this question is code with comments:
private void captureImage() {
try {
captureStillBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
captureStillBuilder.addTarget(mImageReader.getSurface());
captureStillBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
captureStillBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
CaptureRequest.CONTROL_AF_TRIGGER_START);
MeteringRectangle[] focusArea = new MeteringRectangle[1];
focusArea[0] = new MeteringRectangle();
captureStillBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, focusArea);
CameraCaptureSession.CaptureCallback callback = new ...
mCameraCaptureSession.capture(captureStillBuilder.build(), callback, null);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
source
share