Use zxing to generate QR code in Android (support adding logo pattern)

Zxing is an open source library of Google, which can be used to generate and scan QR codes. This paper introduces the first part.

First, the rendering:

Official download address of zxing related documents: https://github.com/zxing/zxing/releases

Or download it here (only the jar package used in this project, version No.: 3.2.0): link: http://pan.baidu.com/s/1pLqAR5x

1. Tool class for generating QR code

2. Use in activity:

3. The picture files in this project are saved in

Under the directory. According to the official API documents, starting from KitKat (Android 4.4), saving files to this directory will not require SD card read-write permission. However, tests show that permissions are not required on Hongmi note and Meizu MX3 (both Android 4.4.4); However, on my Huawei P6 (Android 4.4.2), you must declare permissions to successfully save files, that is, you must add the following contents to the manifest:

Therefore, I guess that the so-called no permission is from Android 4.4.4.

Now let's share the code for Android to generate QR code and add logo

The specific code is as follows:

Well, the code is over. I hope it will help you!

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
分享
二维码
< <上一篇
下一篇>>