我需要在我的android应用程序中创建qrcode,并且我需要一个库或源代码来让我在Android应用程序中创建QR码。
我需要的库必须:
onbarcode库)我已经为iPhone (Objective-C)创建了这样的代码,但在我有时间制作自己的二维码生成器之前,我需要一个针对安卓的快速修复。这是我的第一个android项目,所以任何帮助都将不胜感激。
发布于 2012-01-10 17:29:21
你调查过ZXING吗?我已经成功地用它创建了条形码。您可以在bitcoin application src中查看完整的工作示例
// this is a small sample use of the QRCodeEncoder class from zxing
try {
// generate a 150x150 QR code
Bitmap bm = encodeAsBitmap(barcode_content, BarcodeFormat.QR_CODE, 150, 150);
if(bm != null) {
image_view.setImageBitmap(bm);
}
} catch (WriterException e) { //eek }发布于 2014-08-13 17:53:56
使用zxing,这是我创建QR的代码
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();
}发布于 2015-11-16 11:01:13
也许这是一个古老的话题,但我发现这个库非常有用且易于使用
在android中使用的示例
Bitmap myBitmap = QRCode.from("www.example.org").bitmap();
ImageView myImage = (ImageView) findViewById(R.id.imageView);
myImage.setImageBitmap(myBitmap);https://stackoverflow.com/questions/8800919
复制相似问题