0

I am trying to create a QR that, when read by another device, appears as creating a new Contact.

To create the QR, I have tried the class QRCodeWriter and BitMatrix.

I leave you the code:

  QRCodeWriter writer = new QRCodeWriter();
        try {
            BitMatrix bitMatrix = writer.encode(content, BarcodeFormat.QR_CODE, 512, 512);
            int width = bitMatrix.getWidth();
            int height = bitMatrix.getHeight();
            Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
            for (int x = 0; x < width; x++) {
                for (int y = 0; y < height; y++) {
                    bmp.setPixel(x, y, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE);
                }
            }
            image.setImageBitmap(bmp);

        } catch (WriterException e) {
            e.printStackTrace();
        }
    }

And I would like that when reading the QR, something similar to this would come out

create new contact

Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
Blas Piris
  • 11
  • 2
  • So you want to write an app that takes a picture of a QR code and turns it into a Contact? Because you'd need an app on the device taking the camera to do that, QR codes themselves don't run code on the device scanning it. – Gabe Sechan Jan 17 '23 at 17:18
  • The QR would be read from another device, what would have to be sent in that QR are the data of the new Contact and that the creation of a new contact be executed. – Blas Piris Jan 17 '23 at 17:30
  • You need an app on the device reading the QR code. There's no way to make a QR code automatically add a contact. When you see apps like facebook or snapchat doing this, it only works if the other person has facebook or snapchat on their phone as well. – Gabe Sechan Jan 17 '23 at 17:33
  • Having the application on both devices, I see it as more feasible. Without this second device having it, it would possibly make it very difficult or almost impossible. – Blas Piris Jan 17 '23 at 17:54
  • Possible duplicate: [How to add vCard to contact application via QR code in Android?](https://stackoverflow.com/q/73974098/295004) – Morrison Chang Jan 17 '23 at 19:27
  • I have already managed to get it out, I leave the code in case it can help someone: – Blas Piris Jan 18 '23 at 16:23

0 Answers0