Android uses zxing to realize its own QR code scanning and recognition

preface

In the previous article, we briefly introduced the use of zxing and quickly integrated it into our own project, but we can't make our own scanning interface according to our own needs, so in this article, we'll learn how to realize two-dimensional code scanning according to our own needs. Of course, the library used is still Google's zxing. I won't say much now. Let's take a look at the detailed introduction.

The method is as follows:

First, we open Google's zxing address and Google dezxing address (local download). After opening, we will see such an interface,

Download this file locally. After downloading, we need to copy several classes under the Android file,

According to these class names, find these classes in the Android file and copy them to your project. After copying, there will be an error. We need to copy the files in res under the Android file to our project.

After that, we have to rely on zxing's core class library,

When our project does not report errors, we can scan QR code and generate QR code first.

The logic code scanned is:

Let's just open this activity.

It can be seen that the scanning logic is in captureactivity. Google has helped us implement this. We can call it directly.

If you need to modify the scanning interface effect, you can find its XML layout file in captureactivity and modify it yourself. Basically, Google has encapsulated it for us. Just call it.

The logic to realize the production of QR code is as follows:

Through the above logic, we can realize our QR code generation.

summary

The above is the whole content of this article. I hope the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message. Thank you for your support for programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>