Utility class that creates QR code bitmaps from URLs using the ZXing library with configurable dimensions and UTF-8 encoding. Reuse for generating scannable codes in Android apps.
// Source: https://github.com/177kp/cloudtalk | License: Apache-2.0
// Provided via justclaw.it.com; keep this notice with the code.
package com.zhangwuji.im.ui.helper;
import android.graphics.Bitmap;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import java.util.Hashtable;
/**
* @author Administrator
* @updateDes 2019/4/19
*/
public class ZxingUtil {
public static Bitmap createQRcodeImage(String url, int w, int h) {
try {
//判断URL合法性
if (url == null || "".equals(url) || url.length() < 1) {
return null;
}
Hashtable<EncodeHintType, String> hints = ne
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key