I am using Zxing-android-embedded ( https://github.com/journeyapps/zxing-android-embedded ) to scan QR codes. I imported the library from github. When the application starts, the camera scans the code several times while the camera is placed on the barcode. I want to stop the scan (but not the camera preview) after detecting the barcode and displaying a dialog box with the "Confirm", "Cancel" button and the input field. When the user clicks the Confirm or Cancel button, he must start scanning again.
I called barcodeView.pause(); at the beginning of the decode () method, which pauses the cameraβs preview. In addition, barcodeView.resume(); inside the onClick method is "dialogConfirmClick" and "dialogCancelClick". But the barcodeView.pause(); method barcodeView.pause(); pauses scanning as well as camera preview.
Here is my class -
public class MyScanActivity extends Activity { private static final String TAG = MyScanActivity.class.getSimpleName(); private CompoundBarcodeView barcodeView; private BeepManager beepManager; private DialogInterface.OnClickListener dialogCanselClick; private AlertDialog dialog; private BarcodeCallback callback = new BarcodeCallback() { @Override public void barcodeResult(BarcodeResult result) { if (result.getText() != null) { handleDecode(result); } } @Override public void possibleResultPoints(List<ResultPoint> resultPoints) { } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.continuous_scan); barcodeView = (CompoundBarcodeView) findViewById(R.id.barcode_scanner); barcodeView.decodeContinuous(callback); beepManager = new BeepManager(this); dialogCancelClick = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { barcodeView.resume();
source share