QR codes can be seen everywhere now. using Android code to generate a QR code based on the input string is actually very simple. You need to reference a Google open-source package-ZXing. The following example contains the generation and resolution of the barcode and QR code. The following describes the generation of the QR code. First, the following steps are provided: 1. first, enter the string content to be generated in the edit box. 2. click the button below 3. the ImageView control at the bottom of the button displays the generated QR code and the specific code is given below: 1. interface layout [html] <? Xml version = "1.0" encoding = "UTF-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: background = "@ android: color/white" android: orientation = "vertical"> <Button android: id = "@ + id/btn_scan_barcode" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: layout_marginTop = "30dp" android: text = "Open camera"/> <Lin EarLayout www.2cto.com android: orientation = "horizontal" android: layout_marginTop = "10dp" android: layout_width = "fill_parent" android: layout_height = "wrap_content"> <TextView android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: textColor = "@ android: color/black" android: textSize = "18sp" android: text = "Scan result: "/> <TextView android: id =" @ + id/TV _scan_result "android: layout_wi Dth = "fill_parent" android: textSize = "18sp" android: textColor = "@ android: color/black" android: layout_height = "wrap_content"/> </LinearLayout> <EditText android: id = "@ + id/et_qr_string" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: layout_marginTop = "30dp" android: hint = "Input the text"/> <Button android: id = "@ + id/btn_add_qrcode" android: layout_width = "fill_parent" android: Layout_height = "wrap_content" android: text = "Generate QRcode"/> <ImageView android: id = "@ + id/iv_qr_image" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_marginTop = "10dp" android: layout_gravity = "center"/> </LinearLayout> 2. code for generating a QR code [java] package com. zxing. encoding; import java. util. hashtable; import android. graphics. bitmap; import com. google. zxing. barcodeForma T; import com. google. zxing. encodeHintType; import com. google. zxing. multiFormatWriter; import com. google. zxing. writerException; import com. google. zxing. common. bitMatrix;/*** @ author Ryan Tang **/public final class EncodingHandler {private static final int BLACK = 0xff000000; public static Bitmap createQRCode (String str, int widthAndHeight) throws WriterException {Hashtable <EncodeHintType, Stri Ng> 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 (); int height = matrix. getHeight (); int [] pixels = new int [width * height]; for (int y = 0; y