Java – CWAC Camera – Can I add click-to-focus?

CWAC Camera – Can I add click-to-focus?… here is a solution to the problem.

CWAC Camera – Can I add click-to-focus?

I’m using the Commonsware camera library. My photos look great, but when I get close to something, I want to refocus, but I can’t do it all the time. I followed some of the readme documents seen here:

You can call autoFocus() on CameraFragment or CameraView to trigger
any auto-focus behavior that you have configured via setFocusMode() on
Camera.Parameters. You can call cancelAutoFocus() on CameraFragment or
CameraView to ensure that auto-focus mode has been canceled.

I simply did an onclicklistener on the screen and wanted it to focus again so my picture was clear. Has anyone managed to do this?

Solution

Obviously, you need to cancel AutoFocus() before you can trigger autoFocus() again to get a new autofocus.

I have filed an issue Well, myself, thinking of a better API here.

Related Problems and Solutions