zaheer
zaheer

Reputation: 143

how to stop continuous scanning of QR code?

**this is my code, i want is after a scan for the first-time callApi() method should call, but it keep on scanning **

  @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);
    }

};

Upvotes: 0

Views: 1887

Answers (1)

Milan Pansuriya
Milan Pansuriya

Reputation: 2559

just replace your code with this

    @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);
    }

};

Upvotes: 2

Related Questions