QR code scanner

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 highly appreciated.

0

4 Answers

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.

3

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!

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

Code sample:

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 ( )
  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">
  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">

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

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like