1

I want to share a simple string between two android devices with QR code.

For Scanning the code i use google mobile vision API, but what's the best way to generate it?

All libraries that i found such as Zxing are old and no longer maintained.

ameencarpenter
  • 2,059
  • 1
  • 11
  • 20
  • Yes, "ZXing" is in "maintenance mode". But it's not "old"; and it's very good. I'd encourage you to use it: https://github.com/zxing/zxing – paulsm4 Aug 13 '20 at 02:28
  • @paulsm4 I said that because most of it's questions are closed and looks like it has a lot of problems. Also I couldn't find a straightforward way to use It. Can you tell me how to import it in android studio with an example please! – ameencarpenter Aug 13 '20 at 02:36
  • Try this: https://stackoverflow.com/a/39578827/421195 – paulsm4 Aug 13 '20 at 04:04

1 Answers1

0

You can use library by androidmads/QRGenerator   Backed by Zxing but continuosly maintainted and support.

Features:

  • QR code color can be changed dynamically

implementations

implementation 'androidmads.library.qrgenearator:QRGenearator:1.0.4'
implementation 'com.google.zxing:core:3.3.2'

Creating QR Code from Text

QRGEncoder qrgEncoder = new QRGEncoder(inputValue, null, QRGContents.Type.TEXT, smallerDimension);
qrgEncoder.setColorBlack(Color.RED);
qrgEncoder.setColorWhite(Color.BLUE);
try {
     // Getting QR-Code as Bitmap
     bitmap = qrgEncoder.getBitmap();
     // Setting Bitmap to ImageView
     qrImage.setImageBitmap(bitmap);
  } catch (WriterException e) {
     Log.v(TAG, e.toString());
 }

Save QR Code Image

QRGSaver qrgSaver = new QRGSaver();
qrgSaver.save(savePath, edtValue.getText().toString().trim(), bitmap, QRGContents.ImageType.IMAGE_JPEG);
Ranjeet Chouhan
  • 686
  • 5
  • 13