简体   繁体   中英

ZXing barcode scanner to read Brazilian barcode

I'm aware that there is another post with the same topic here in the forum, but I coulnd't solve my problem and I've tried everything and it doesn't work.

Here is the thing, I've tried to make barcodeScanner, from ZXing, to read barcode format interleaved 2 of 5 , in an android I'm developing, but it doesn't work. The Scanner keep with the red light in the screen but doesn't read the bar code at all.

I'm using the "android-integration-2.3.0.jar", downloaded from here http://mvnrepository.com/artifact/com.google.zxing/android-integration/2.3.0 , but it doesn't read my bar code at all. I'm sure that the problem is not with my barcode, it's an official one from a famous bank here. This is the tutorial that I've followed : http://techiedreams.com/android-zxing-barcode-scanner-integration/

Anyway, let me show you some code: this is how I'm invoking the barCodeScanner

ImageView ivBarCode = (ImageView) findViewById(R.id.ivPagamentosCodBar); ivBarCode.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent("com.google.zxing.client.android.SCAN");
            intent.putExtra("SCAN_FORMATS", "AZTEC,CODABAR,CODE_39,CODE_93,CODE_128,DATA_MATRIX,EAN_8,EAN_13,ITF,MAXICODE,PDF_417,QR_CODE,RSS_14,RSS_EXPANDED,UPC_A,UPC_E,UPC_EAN_EXTENSION");
            startActivityForResult(intent, 0);
        }
    });

and This is how i'm reading the information: or at least, think it should work:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//      if (data == null) {
//          ringProgressDialog.dismiss();
//          return;
//      }else 
        if (requestCode==IntentIntegrator.REQUEST_CODE)
        {
            IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
            if (scanResult != null)
            {
               String codBar = scanResult.toString();
               Toast.makeText(PagamentosContas.this, codBar, Toast.LENGTH_LONG).show();
               Log.e("Código de Barras",codBar);
               Log.e("Código de Barras",codBar);
               Log.e("Código de Barras",codBar);

            }
            else
            {
                // else continue with any other code you need in the method
               Toast.makeText(PagamentosContas.this, "scanResult is null.",     Toast.LENGTH_LONG).show();
            }
    }
//      else{
//      String valor = data.getStringExtra("valor");
//      valor = valor.replace(",", ".");
//
//      pagamento.setValorConta(valor);
//      ThreadPagamentosContas thread1 = new ThreadPagamentosContas();
//      thread1.start();
//      ringProgressDialog.dismiss();
//      }

    }

it doesn't read any barcode at all, or when it does, do it wrong, took an interleaved 2 of 5 by an EAN3...

here is an example of an official barcode: https://drive.google.com/file/d/0ByQMtFUGwDRBWnZObkFBcDR1RVk/edit

thanks in advance. this is driving me crazy for months now...

I've found the problem! Everything on the tutorial is right and works fine. The problem was the camera of ALL devices I have for testing.

Last week I've got a better smartphone, with better resources and it reads the barcode just fine. Tablets usually don't have an autofocus tool in the camera hardware, so it cannot focus the barcode properlly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM