zxing-android-embedded
zxing-android-embedded copied to clipboard
Duplicate call method 'barcodeResult'
Android Studio 3.6
in app/build.gradle:
implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
in fragment
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
ScanCodeBinding binding = DataBindingUtil.inflate(inflater, R.layout.scan_code, container, false);
binding.setHandler(this);
View rootView = binding.getRoot();
`decoratedBarcodeView.decodeContinuous(bacCodeCallback);`
return rootView;
}
private BarcodeCallback bacCodeCallback= new BarcodeCallback() {
@Override
public void barcodeResult(BarcodeResult result) {
}
@Override
public void possibleResultPoints(List<ResultPoint> resultPoints) {
}
};
@Override
public void onResume() {
super.onResume();
decoratedBarcodeView.resume();
}
@Override
public void onPause() {
super.onPause();
decoratedBarcodeView.pause();
}
but method barcodeResult
call TWICE after scan.
This is expected - decodeContinuous will call the method every time it detects a barcode. You need to implement your own filtering of the results. For example, you can add a check to ignore barcodes if another one has been scanned less than a second ago, or if the data is the same as the previous scan.