如何知道条形码已被扫描?

How to find out that the Barcode has been scanned?

我有这个方法来生成条码位图:

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;
}

有什么办法可以知道条码已经被扫描过了吗?我正在使用 zxing.

如果我对你的理解正确的话,你正在寻找一种方法来

  1. 创建包含二维码的位图
  2. 在您的设备上显示该位图
  3. 当不使用您的软件的其他设备扫描该代码时进行检测

这是不可能的。 QR 码位图就是:您的应用程序显示的位图。条形码扫描仪应用程序只需为您的显示器拍照并尝试在该位图中找到图案。