Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QR code scanner

Tags:

android

zxing

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.

like image 626
hitansu jena Avatar asked Mar 31 '11 09:03

hitansu jena


People also ask

Can I scan a QR code without an app?

To scan a QR Code with Google Screen Search, you don't need an app. You can use the following steps to scan a QR Code: Point your camera at the QR Code. Hold down the “Home” button and swipe up to reveal the options at the bottom.

How do I scan QR code?

On your compatible Android phone or tablet, open the built-in camera app. Point the camera at the QR code. Tap the banner that appears on your Android phone or tablet. Follow the instructions on the screen to finish signing in.

Where can I find a QR code reader?

To scan QR code on Android, open the Camera app and position the QR code within the frame. If that doesn't work, you can use the Google Lens feature in the Google Search app.

Which QR code scanners are free?

Kaspersky QR Scanner is one of the best free third-party scanning apps for iOS and Android. Developed by the cybersecurity experts at Kaspersky, it does what you'd expect a QR scanning app from a cybersecurity company to do: scan for unsafe and malicious QR codes.


2 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.

like image 168
jengelsma Avatar answered Sep 23 '22 11:09

jengelsma


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!

like image 27
Andres Santiago Avatar answered Sep 22 '22 11:09

Andres Santiago