Question

In my app, I use zxing as a library and when I scan a QR code it shows for default a screen with the QR data.

Instead of this, I want to go to another Activity depending on the QR code scanned.

Can anybody help me please?

This is my code in my Activity:

public void onActivityResult(int requestCode, int resultCode, Intent intent) 
{
    //super.onActivityResult(requestCode, resultCode, intent);
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {
            String contenido = intent.getStringExtra("SCAN_RESULT");
            String formato = intent.getStringExtra("SCAN_RESULT_FORMAT");

            Intent i = new Intent(Qr_Reader.this,AnotherAcitvity.class);
            startActivity(i);

        } else if (resultCode == RESULT_CANCELED) {

        }
    }
}
Was it helpful?

Solution

Try this code from zxing barcode result:

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case IntentIntegrator.REQUEST_CODE:
                IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode,
                        resultCode, data);
                if (scanResult == null) {
                    return;
                }
                final String result = scanResult.getContents();
                final String result1 = scanResult.getFormatName();
                if (result != null) {
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            txtScanResult.setText(result);
                            txtScanResultFormat.setText(result1);

                             Intent i = new Intent(Qr_Reader.this,AnotherAcitvity.class);
                             startActivity(i);
                        }
                    });
                }
                break;
            default:
        }
    }

EDIT:

If you want to do without using IntetIntegrator then try this code.

I have not tried this way but I have found some link it may help you.

Link1

Link2

Hope it will help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top