QR code scanner

后端 未结 4 1246
醉话见心
醉话见心 2020-12-03 08:50

I would like to create a QR code scanner in my app.

I went through the zxing ,but I could not understand it. I am interested in QR codes only.

All help is hi

相关标签:
4条回答
  • 2020-12-03 09:18

    I know this is an old question, but thought someone might find this useful.

    I recently released a qr reader app, and ZXing really is the go-to library on Android. However, I found working with a copy of the source of ZXing project difficult. There is already a library that handles the ZXing core, and even optimizes it for custom usage.

    Try zxing-android-embedded:

    • Super easy to add to your app.
    • Takes care of opening camera in background thread for performance.
    • Has docs/examples for custom usage of the scanner.
    • Authors respond fast and commit once every 2 weeks :)

    I put a guide on this post.

    Hope this helps!

    0 讨论(0)
  • 2020-12-03 09:29

    I did it using a set of plugins, plus I inserted my own additions to make it a 1-stop setup.

    1. unzip the attached zip file into your project ( https://github.com/chwagssd/qr/archive/master.zip )
    2. point to <script src="path/to/decoder.js"><script>
    3. Create a file input in your HTML page that has an id, say "xxx"

      <input type="file" id="xxxx">
      
    4. Then tell the page on load to QRIfy your field! Make sure to include your callback function, which will be called with a single argument (the FULL TEXT that was scanned): QRIfy('qrCode', onQrCode);//where qrCode is the id of your

      <input type="file" id="xxxx">
      

    I have setup a GIT repo here, grab the code (you can download the zip and put it in your javascript folder)

    https://github.com/chwagssd/qr

    0 讨论(0)
  • 2020-12-03 09:36

    There is now an google API for that call Mobile vision.

    Code sample: https://github.com/googlesamples/android-vision/tree/master/visionSamples/barcode-reader

    0 讨论(0)
  • 2020-12-03 09:41

    Place a copy of the com.google.zxing.client.* source packages into your project. You can start the zxing scanning activity like this:

    Intent intent = new Intent(this, CaptureActivity.class);
    startActivityForResult(intent, 0);
    

    In the same activity that you invoked the CaptureActivity in you can handle the result when the scan completes with the following onActivityResult method:

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            if (data != null) {
                String response = data.getAction();
    
                if(Pattern.matches("[0-9]{1,13}", response)) {
                    // response is a UPC code, fetch product meta data
                    // using Google Products API, Best Buy Remix, etc.          
                } else {
                    // QR codes - phone #, url, location, email, etc. 
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setData(Uri.parse(response));
                    startActivity(intent);
                }
            }
        }   
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题