user3232446
user3232446

Reputation: 439

How to find out that the Barcode has been scanned?

I have this method to generate a Barcode bitmap:

public static Bitmap encodeToQrCode(String text, int width, int height) {
    QRCodeWriter writer = new QRCodeWriter();
    BitMatrix matrix = null;
    try {
        matrix = writer.encode(text, BarcodeFormat.QR_CODE, 400, 400);
    } catch (WriterException ex) {
        ex.printStackTrace();
    }
    Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height - 1; y++) {
            bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE);
        }
    }
    return bmp;
}

Is there any way to find out that the Barcode has been scanned? I'm using zxing.

Upvotes: 0

Views: 621

Answers (1)

Thorsten Dittmar
Thorsten Dittmar

Reputation: 56707

If I understand you correctly you're looking for a way to

  1. Create a bitmap that contains a QR code
  2. Display that bitmap on your device
  3. Detect when a different device that doesn't use your software scans that code

This is not possible. The QR code bitmap is just that: A bitmap your app displays. And a barcode scanner app simply takes a photo of your display and tries to find patterns in that bitmap.

Upvotes: 1

Related Questions