前端生成二维码,根据后台的一个支付的url来生成,使用zxing.jar
过程很简单,直接上代码
public class EncodingHandler
{
private static final int BLACK = 0xff000000;
private static final int WHITE = 0xffffffff;
public static Bitmap createQRCode(String str,int widthAndHeight) throws WriterException {
Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
BitMatrix matrix = new MultiFormatWriter().encode(str,
BarcodeFormat.QR_CODE, widthAndHeight, widthAndHeight);
int width = matrix.getWidth();