nisrulz / qreader

:white_square_button: [Android Library] Read QR codes using google's mobile vision api, but without the hassle
http://nisrulz.github.io/qreader
Apache License 2.0
371 stars 108 forks source link

Start activity in onDetected() and then pressing back #59

Closed Alessandrolosco closed 3 years ago

Alessandrolosco commented 6 years ago

I'm trying to scan a qrcode, parse data, put this data into an intent and launch another activity. Everything works fine but when I press the back button to return in the scan activity, surfaceview is completely black. How do you suggest I can solve this? Thank you very much

Here is my code


@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_qr_code_scan);
        text = findViewById(R.id.text);
        requestPermissions();
        // Setup SurfaceView
        // -----------------
        mySurfaceView = (SurfaceView) findViewById(R.id.camera_view);
        // Init QREader
        // ------------
        qrEader = new QREader.Builder(this, mySurfaceView, new QRDataListener() {
            @Override
            public void onDetected(final String data) {
                Log.d("QREader", "Value : " + data);
                createLetturaQrCode(data);
                text.post(new Runnable() {
                    @Override
                    public void run() {
                        //text.setText(data);
                    }
                });
                Intent intent = new Intent(thisActivity, QrCodeDetailsActivity.class);
                intent.putExtra(QRCODE_DETAILS, data);
                startActivity(intent);
            }
        }).facing(QREader.BACK_CAM)
                .enableAutofocus(true)
                .height(mySurfaceView.getHeight())
                .width(mySurfaceView.getWidth())
                .build();
    }
MahmoudMabrok commented 5 years ago

move all codes of qreader to onResume().

nisrulz commented 3 years ago

Closing as issue is outdated. Please open a new issue if the issue still persists.