android – CameraX AF-S / MF-ThrowExceptions

Exception or error:

Is it possible to set the camera focus to AF-S or MF using CameraX?

I don’t want my camera to focus automaticaly.

I’ve been making some google search about it, but didn’t found anything about this subject yet.

Is it possible to use Camera2 capabilities on CameraX in order to achive this?

How to solve:

After some debug just found how to AF-S instead of AF-C with CameraX.

By default when you set a FocusMeteringAction it has a default cancelation of 5secs, what does it mean?

After you tap for focus or focus in an area for example after 5 secs it will automaticaly cancel your FocusMeteringAction and return to AF-C mode.

In order to AF-S in CameraX the only thing you need to do is to disableAutoCancel() when you are building your FocusMeteringAction.

Make sure that you manually cancel your previous FocusMeteringAction before you create a new one with cancelFocusAndMetering().

Leave a Reply

Your email address will not be published. Required fields are marked *