我在我的android项目中使用budiyev:代码扫描仪库来扫描二维码。它处于连续扫描模式。有没有办法在一次扫描到另一次扫描时设置一个小的延迟时间。现在它一眨眼就能扫描多个记录
mCodeScanner = new CodeScanner(getActivity(), binding.scannerView);
mCodeScanner.setCamera(CodeScanner.CAMERA_BACK);
mCodeScanner.setFormats(CodeScanner.ALL_FORMATS);
mCodeScanner.setAutoFocusMode(AutoFocusMode.SAFE);
mCodeScanner.setScanMode(ScanMode.CONTINUOUS);
@Override
public void onDecoded(@NonNull final Result result) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
binding.scanCode.setText(result.getText());
scannedQr = result.getText();
getDetails(scannedQr);
}
});
}
我找到了做这件事的方法。当扫描事件触发时,您必须释放扫描仪资源,以便它再次停止扫描。工作完成后,再次调用mCodeScanner.startPreview();
@Override
public void onDecoded(@NonNull final Result result) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
binding.scanCode.setText(result.getText());
scannedQr = result.getText();
mCodeScanner.releaseResources();
getDetails(mCodeScanner);
}
});
}