Hi I checked the barcode reader sample from google on github , I am trying to just make the barcodedetector detect the first barcode (only one) and when it does it send the decoded barcode to another activity. Mabye I am wrong but I need to put this code
BarcodeGraphic graphic = mGraphicOverlay.getFirstGraphic();
Barcode barcode = null;
if (graphic != null) {
barcode = graphic.getBarcode();
if (barcode != null) {
Intent data = new Intent();
data.putExtra(BarcodeObject, barcode);
setResult(CommonStatusCodes.SUCCESS, data);
finish();
}
else {
Log.d(TAG, "barcode data is null");
}
}
else {
Log.d(TAG,"no barcode detected");
}
return barcode != null;
}
somewhere in this one so that the barcode is captured automatically without that I need to tap when barcode graphic appears.I also figured that I dont need the MultiProcessor.Builder<>
BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context).build();
BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay);
barcodeDetector.setProcessor(
new MultiProcessor.Builder<>(barcodeFactory).build());
I was after the same outcome. Here is how i accomplished it.
Add a listener to
BarcodeTracker
:This listener is fired whenever the create method is called when a new barcode is detected.
Next, from the
BarcodeCaptureActivity
, under thecreateCameraSource
method attach a new listener and send the barcode wherever you'd like it.Hope that helps!