Android Question CameraEx : How to achieve "touch to focus"


Licensed User
Longtime User
Hi Guys,

I have searched high and low, and I cannot find any pointers on how to achieve camera focus by touching the camera preview...

Any help will be very welcome


Well-Known Member
Licensed User
Longtime User
there is no "touch to focus" in the API's for Camera 1 or Camera 2.
it is possible to implement touch to focus for Camera 2, but it is
not part of the API. if you have a recent device whose built-in
camera app supports touch to focus, i suggest you use it and
share the resultant image with your app (or you could start the
camera app with an intent and access the image that way).

as mentioned above, several implementations of touch to focus
are available. presumably they could be wrapped for B4A, but
using Camera 2 would be required (and its B4A class Cam Ex2).

the CameraEx class uses the API of the so called Camera 1
hardware. there are a limited number of focus tweaks
available (fixed, infinity, closeup, auto). they are available in the
CameraEx class. since google is not do any more development
for Camera 1, there is, essentially, nothing to "maintain" in the
CameraEx class. there is, however, nothing stopping you from
modifying the class yourself, as it is written in B4X.

Note: even though a particular method or setting may be
exposed in the API, a device's camera hardware may not
necessarily support it. this is made clear in google's
documentation: device manufacturers supply their own
Upvote 0