@Override public void onClick(View view) { // Se responde al evento click if (view.getId() == R.id.scan_button) { // Se instancia un objeto de la clase IntentIntegrator IntentIntegrator scanIntegrator = new IntentIntegrator(this); // Se procede con el proceso de scaneo scanIntegrator.initiateScan(); } }
public void onActivityResult(int requestCode, int resultCode, Intent intent) { // Se obtiene el resultado del proceso de scaneo y se parsea IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanningResult != null) { // Quiere decir que se obtuvo resultado por lo tanto: // Se trabaja con la peticion en el servidor this.folioData = scanningResult.getContents(); if (CencelUtils.isNumeric(this.folioData)) { (new PushToServerHelper()) .execute( CencelUtils.buildUrlRequest( Qrlector.this, getString(R.string.getEstatusDataMethod))); } else { Toast.makeText( getApplicationContext(), getApplicationContext().getString(R.string.not_number_message), Toast.LENGTH_SHORT) .show(); } } else { // Quiere decir que NO se obtuvo resultado Toast toast = Toast.makeText( getApplicationContext(), "No se ha recibido datos del scaneo!", Toast.LENGTH_SHORT); toast.show(); } }