Git Product home page Git Product logo

Comments (7)

MahmoudMabrok avatar MahmoudMabrok commented on July 30, 2024 2

call qReader.stop() after first scan.
and use qReader.start() when need to start scanning again.

from qreader.

BhagirathParmar avatar BhagirathParmar commented on July 30, 2024 2

private void SetupQREader() {
qrEader = new QREader.Builder(this, id_SurfaceView, new QRDataListener() {
@OverRide
public void onDetected(final String data) {
Log.d("QREader", "Value : " + data);

            result.post(new Runnable() {
                @Override
                public void run() {
                    String msg;
                    result.setText(data);
                    qrEader.stop();
                    msg = result.getText().toString();
                    Log.e("XXXXX", msg);
                    Intent intent = new Intent(ac, QrCodeResult.class);
                    intent.putExtra("RESULT", msg);
                    startActivity(intent);
                }
            });
        }
    }).facing(QREader.BACK_CAM)
            .enableAutofocus(true)
            .height(id_SurfaceView.getHeight())
            .width(id_SurfaceView.getWidth())
            .build();
}

still getting Log two times ? why ? not understanding.
and what is the use of qrEader.wait(); and how do i use and where to use?

call qReader.stop() after first scan.
and use qReader.start() when need to start scanning again.

from qreader.

trix0 avatar trix0 commented on July 30, 2024
        public void onDetected(final String data) {
            Log.d("QREader", "Value : " + data);
            Gson Gson = new Gson();
            try {
                QrCodeMessage qrCodeMessage = Gson.fromJson(data, QrCodeMessage.class);
                if(qrCodeMessage!=null){
                    if(qrCodeMessage.company.equals("MyTestData")){
                        Log.d(TAG,"Valid QR code");
                        qrEader.stop();
                    }
                }
            }
            catch (Exception e){
                Log.d(TAG,"Couldn't parse");
            }
        }


@Override
public void onResume() {
    super.onResume();
    qrEader.initAndStart(mySurfaceView);
    qrEader.start();
    mySurfaceView.setOnClickListener((click)->{
        qrEader.start();
    });
}

onclick throws java.lang.IllegalStateException: Camera already started!

but It Doesn't scan again. Any idea how to fix this ?

from qreader.

MahmoudMabrok avatar MahmoudMabrok commented on July 30, 2024

@trix0 u start it before click, why start it again
surround it with try /catch

from qreader.

trix0 avatar trix0 commented on July 30, 2024

from qreader.

MahmoudMabrok avatar MahmoudMabrok commented on July 30, 2024

@trix0
with try and catch
it will first try to start
if it failed which mean it already started
so catch will be called
so app is safe and also app function is right

from qreader.

nisrulz avatar nisrulz commented on July 30, 2024

The behavior is correct. The library when it was initially written didn't allow for restarting without stopping it. This issue is too old now and the library would undergo upgrades soon. Open a new one if the issue persists.

from qreader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.