Android 库生成的二维码无法被二维扫描仪读取-正在寻找生成二维码的可靠方法
我正在尝试在我的应用程序中生成二维码 我尝试了几个关于堆栈溢出的答案 我可以使用这个库生成二维码- 但二维码扫描器无法读取此库生成的二维码,尽管它可以读取其他二维码Android 库生成的二维码无法被二维扫描仪读取-正在寻找生成二维码的可靠方法,android,qr-code,Android,Qr Code,我正在尝试在我的应用程序中生成二维码 我尝试了几个关于堆栈溢出的答案 我可以使用这个库生成二维码- 但二维码扫描器无法读取此库生成的二维码,尽管它可以读取其他二维码 有没有可靠的方法在android应用程序上生成二维码 您可以直接在android应用程序中使用Zxing库,而不是使用QRGen,并使用下面显示的代码生成QRcode QRCodeWriter writer = new QRCodeWriter(); try { BitMatrix bitMatrix = writer
有没有可靠的方法在android应用程序上生成二维码 您可以直接在android应用程序中使用Zxing库,而不是使用QRGen,并使用下面显示的代码生成QRcode
QRCodeWriter writer = new QRCodeWriter();
try {
BitMatrix bitMatrix = writer.encode(content, BarcodeFormat.QR_CODE, 512, 512);
int width = bitMatrix.getWidth();
int height = bitMatrix.getHeight();
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
bmp.setPixel(x, y, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE);
}
}
((ImageView) findViewById(R.id.img_result_qr)).setImageBitmap(bmp);
} catch (WriterException e) {
e.printStackTrace();
}
现在测试。我能得到源代码吗???应该在github上吗?
repositories {
jcenter()
}
dependencies {
implementation 'com.google.zxing:core:3.3.0'
}