Simplified & Efficient Integration of Huawei Scan Kit in Xamarin Android App
Huawei Scan Kit allows reading barcodes in any form like 1D and 2D. It also provides the best scan mechanism to detect, magnifie and recognize the barcodes. it automatically captures the whole barcode even in lowlight, reflective, dirty, blurry, or printed.
Overview
In this article, I will create a demo app along with the integration of Huawei Scan Kit which is based on Cross-platform Technology Xamarin. User can easily scan 1D and 2D barcodes using this application. This Xamarin based application easily detects, magnifies, and recognizes barcodes from a distance. I will provide the easy way of implementing scan kit in Xamarin app.
Service Introduction
Huawei Scan Kit allows reading barcodes in any form like 1D and 2D. It also provides the best scan mechanism to detect, magnifie and recognize the barcodes. it automatically captures the whole barcode even in lowlight, reflective, dirty, blurry, or printed.
Scan Kit supports 13 formats of barcodes such as-
1D barcodes: EAN-8, EAN-13, UPC-A, UPC-E, Codabar, Code 39, Code 93, Code 128, and ITF
2D barcodes: QR code, Data Matrix, PDF417, and Aztec
Scan Kit provides 4 views of scan barcodes.
1. Default View- Scan barcodes using the camera or from images in the album.
2. Customized View- Scan barcodes using the camera.
3. Bitmap- Scan barcodes using the camera or from images in the album.
4. Multiprocessor- Scan barcodes using the camera or from images in the album.
Recognize multiple barcodes simultaneously.
Work with ML Kit to recognize different objects (such as barcodes and faces) at the same time.
Prerequisite
1. Xamarin Framework
2. Huawei phone
3. Visual Studio 2019
App Gallery Integration process
1. Sign In and Add or Choose a project on AppGallery Connect portal
2. Navigate to Project Setting > Add app
3. Add SHA-256 key
4. Navigate to Project settings > download the configuration file
Xamarin Scan Kit Setup Process
1. Download Xamarin Plugin all the aar and zip files from below URL-
2. Open the XHmsScan-1.2.3.300.sln solution in Visual Studio
3. Navigate to Solution Explorer > Right click on jar > Add >Exsiting Item and choose aar file which downloaded in Step 1
4. Right click on added aar file then choose Properties > Build Action > LibraryProjectZip
Note- Repeat Step 3 & 4 for all aar file
5. Build the Library and make DLL files
6. Success Build
Xamarin App Development
1. Open Visual Studio 2019 and Create a new project
2. Navigate to Solution Explore > Project > Add Folder > Add Json file
3. Navigate to Solution Explore >Project > Add > Add New Folder and keep all DLL files
4. Navigate to Folder(created) > Add > Add Existing and add all DLL files then Select all DLL files and Right Click > Properties >Build Action >None
5. Navigate to Solution Explore > Project > Reference > Right Click > Add References then Navigate to Browse and add all DLL files from recently added Folder
6. Navigate to Solution Explore > Project > Add > Class > Activity
MainActivity.cs
In this activity, I will redirect all the scan view based activity.
DefaultActivity.cs
In this activity, I will start scanning using the scan SDK.
ImageActivity.cs
In this activity, Opening image gallery to get a QR code-based image.
In this activity, I am creating a Custom view and adding into frame layout.
Xamarin App Build Result
1. Navigate to Solution Explore > Project > Right Click > Archive/View Archive to generate SHA-256 for build release
2. Click on Distribute
3. Choose Distribution Channel > Ad Hoc to sign apk
4. Choose Demo Keystore to release apk
5. Let us build the apk and save
6. Finally here is the result
Tips and Tricks
1. Xamarin.Android SDK version should be 11.0.2.0 or later.
2. HMS Core Scan SDK 1.1.0.300 and later support non-Huawei Android phones
3. The recognition and decoding algorithms of different APIs are the same.
4. Scan Kit processes data only on devices and does not store any personal data, ensuring private data security.
Conclusion
In this article, we have learned how to integrate Huawei Scan Kit in Xamarin based Android application.
User can easily scan any image 1D and 2D barcodes using this application without facing any issue or struggle.
Thanks for reading this article. Be sure to like and comments to this article if you found it helpful. It means a lot to me.
References