getpreviewbitmap is, more or less, the corresponding camera2
version. you call it with a timer. but you'll have an issue with the
barcode reader: it wants the preview's original raw byte array, not
a bitmap. i don't know how comfortable you are modifying that
particular sub with its mix of b4a and javaobject code.
(for example,
where it says:
frameBuilder.RunMethod("setImageData", Array(bb, cs.Width, cs.Height, ...
you could change that to:
frameBuilder.runmethod("setBitmap", array( bitmap ))
to handle the bitmap from getpreviewbitmap. of course, the
name of the sub would have to be changed, as well as a couple other
minor changes. i don't know what you're up to handling.)
if your app is a barcode reading app, you should be using the mobile
vision version with the old camera api. if your app uses camera2 and
you suddenly got the brilliant idea to do barcodes, you have a problem.
either you decode barcodes from a static image or you add the barcode
reader as a second activity. there is no reason why you can't use
camera2 in a main activity, release it and start your barcode activity.
if the main purpose of your app is to read barcodes, then you need to
return to the drawingboard. if your app only needs to read a barcode
occasionally, then the 2 options mentioned above should do the trick.