生成QR code在Android中使用Java
问题描述:
有谁知道如何使用Java程序生成QR code?我需要一个应用程序生成QR code对于给定的细节的Android设备。谢谢!
Does anyone knows how to generate QR code using Java program? I need to make an application to generate QR code for given details to Android device. Thank you!
答
尝试ZebraCrossing(ZXing),它看起来很不错:的 HTTP://$c$c.google.com/p/zxing/
Try ZebraCrossing (ZXing), it looks good: http://code.google.com/p/zxing/
String contents = "Code";
BarCodeFormat barcodeFormat = BarCodeFormat.QR_CODE;
int width = 300;
int height = 300;
MultiFormatWriter barcodeWriter = new MultiFormatWriter();
BitMatrix matrix = barcodeWriter.encode(contents, barcodeFormat, width, height);
BufferedImage qrCodeImg = MatrixToImageWriter.toBufferedImage(matrix);