Try this
public void generateQRCode_general(String data, ImageView img)throws WriterException {
com.google.zxing.Writer writer = new QRCodeWriter();
String finaldata = Uri.encode(data, characterEncoding);
BitMatrix bm = writer.encode(finaldata, BarcodeFormat.QR_CODE,bitmapWidth, bitmapHeight);
ImageBitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight,Config.ARGB_8888);
for (int i = 0; i < bitmapWidth; i++) {
for (int j = 0; j < bitmapHeight; j++) {
ImageBitmap.setPixel(i, j, bm.get(i, j) ? Color.BLACK: Color.WHITE);
}
}
if (ImageBitmap != null) {
img.setImageBitmap(ImageBitmap);
} else {
Toast.makeText(activity,"Uable to setImageBitmap \n ImageBitmap is NULL",Toast.LENGTH_LONG).show();
}
}
for Numbers use this
com.google.zxing.Writer writer = new UPCAWriter();
String finaldata = Uri.encode(data, characterEncoding);
BitMatrix bm = writer.encode(finaldata, mBarcodeFormat, bitmapWidth,bitmapHeight);
ImageBitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight,Config.ARGB_8888);
for (int i = 0; i < bitmapWidth; i++) {
for (int j = 0; j < bitmapHeight; j++) {
ImageBitmap.setPixel(i, j, bm.get(i, j) ? Color.BLACK: Color.WHITE);
}
}
UPCA has limit of 12 numbers
solved Android Qr code generation [closed]