как остановить непрерывное сканирование QR-кода? - PullRequest
0 голосов
/ 12 ноября 2018

** это мой код, я хочу, чтобы после сканирования для первого вызова метода callApi () должен вызываться, но он продолжает сканирование **

  @Override
public void handleResult(Result result) {

    System.out.print("BAR_CODE  "+ result.getContents());
    System.out.print("BAR_CODEE  "+result.getBarcodeFormat().getName());
    barcode_number = result.getContents();
    productcode.setText(result.getContents());

    //resume Camera
    scanner_bar.resumeCameraPreview(this);

    dialog = new ProgressDialog(getActivity());
    dialog.setCancelable(true);
    dialog.setTitle("Loading");
    dialog.show();

    //callApi
    if(barcode_number != "") {

        callApi(barcode_number);
    }

};

1 Ответ

0 голосов
/ 12 ноября 2018

просто замените ваш код этим

    @Override
public void handleResult(Result result) {

    System.out.print("BAR_CODE  "+ result.getContents());
    System.out.print("BAR_CODEE  "+result.getBarcodeFormat().getName());
    barcode_number = result.getContents();
    productcode.setText(result.getContents());

    //resume Camera
    scanner_bar.resumeCameraPreview(this);

    dialog = new ProgressDialog(getActivity());
    dialog.setCancelable(true);
    dialog.setTitle("Loading");
    dialog.show();

    //callApi
    if(barcode_number != "") {
        scanner_bar.stopCamera(); 
        callApi(barcode_number);
    }

};
...