Today I am going to write blog on how to scan Qrcode using Mobile Vison Api .I have found it most efficient in scanning QR code.
Followings steps are required to achieve this task.
1. Add compile 'com.google.android.gms:play-services-vision:10.2.1' dependency in build.gradle of app.
2. Design the UI of the app which include SurfaceView for camera preview and textview for storing qrcode
information.
3. Using BarcodeDetector.Builder set the barcode format to QRcode.
4. Using Camera Source set the preview size for scanning the Qrcode.The dimension of the preview size should
be set to the dimension of SurfaceView as defined in xml.
5. Attach callback to the SurfaceView.Inside the Surface Created method start the CameraSource for Scanning
the QRcode and in surfaceDestroyed method stop the CameraSource.
6. We can set Processor to Barcodedetector and obtain the QR Code value read and set it to the textview.That's it.
Complete implementation of code can be found here:https://github.com/piyushdubey529/qrcodeScanner
THANKS
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Piyush Dubey
Piyush is a good learner & innovative. He is passionate about coding and likes to watch cricket & listening music. He has worked on projects like ZipPosRepots, ZipOrdering.