I used the zxing-1.3 jar, and I had to make some changes to the code implementation from other answers, so I will leave my solution to others. I have done the following:
1) find zxing-1.3.jar, download it and add properties (add external jar).
2) in the activity layout add an ImageView and name it (in my example it is tnsd_iv_qr).
3) include the code in my activity to create a qr image (in this example, I created a QR for bitcoin payments):
QRCodeWriter writer = new QRCodeWriter(); ImageView tnsd_iv_qr = (ImageView)findViewById(R.id.tnsd_iv_qr); try { ByteMatrix bitMatrix = writer.encode("bitcoin:"+btc_acc_adress+"?amount="+amountBTC, BarcodeFormat.QR_CODE, 512, 512); int width = 512; int height = 512; Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (bitMatrix.get(x, y)==0) bmp.setPixel(x, y, Color.BLACK); else bmp.setPixel(x, y, Color.WHITE); } } tnsd_iv_qr.setImageBitmap(bmp); } catch (WriterException e) {
If someone wonders, the variable "btc_acc_adress" is a string (with a BTC address), amountBTC is double, and, of course, the transaction amount.
Adam Staszak Dec 01 2018-12-14T00: 00Z
source share