Only code that generates the QR code
The advantage is that the number of occupancy methods is less than 65535
public class Qrcodeutil {static Paint paint;static {paint = new Paint ();//Set a brush size of 3 yellow brush Paint.setcolor (color.black);p Aint.setstrokejoin (Paint.Join.ROUND);p aint.setstrokecap (Paint.Cap.ROUND);p aint.setstrokewidth (3);} private static final int pic_size = 300;private static final int rect_size = 6;/** * Generate two-dimensional code (QRCODE) Picture * * @param content * @param */public Bitmap Encoderqrcode (String content) {Canvas G;try {qrcode Qrcodehandler = new QRCode (); qrcodehandler.se Tqrcodeerrorcorrect (' M '); Qrcodehandler.setqrcodeencodemode (' B '); qrcodehandler.setqrcodeversion (8); byte[] Contentbytes = Content.getbytes ("Utf-8"); Bitmap Bufferbitmap = Bitmap.createbitmap (Pic_size, Pic_size, Bitmap.Config.ARGB_8888); g = new Canvas (BUFFERBITMAP); G.drawcolor (Color.White)///Set offset not set may cause parsing error int pixoff = 2;//output content > QR code if (contentbytes.length > 0 && cont Entbytes.length <) {boolean[][] codeout = Qrcodehandler.calqrcode (contentbytes); for (int i = 0; i < Codeout.len Gth i++) {for (int j = 0; J < Codeout.length; J + +) {if (Codeout[j][i]) {Float left = J * rect_size + pixoff;float top = i * rect_size + pixoff;float right = (j + 1) * R Ect_size + pixoff;float Bottom = (i + 1) * rect_size + pixoff;g.drawrect (left, top, right, bottom, paint);}}} else {log.e ("Qrcodeencoderhandler", "qrcode content bytes Length =" + contentbytes.length+ "not in [0,120].");} return bufferbitmap;} catch (Exception e) {e.printstacktrace (); return null;}}}
Android uses Qrcode_swetake.jar to generate two-dimensional code