-1

I only need to generate a QRCode, I do not need to scan the QRCode.

I can successfully generate the QRCode, but when I generate said code on an Android device without Google Play Services installed, I receive an error alert for a split second. But the error alert leaves the screen almost immediately and the QRCode is successfully displayed. The error alert is on the screen for such a short amount of time that you can't even read it.

The error alert says this:

This app won't run without Google Play services, Which are missing from your phone.

Despite this 'error' alert, the app runs fine and the QRCode is still successfully generated.

Can anyone tell me if this is a bug in the ZXing library? Or if there's something wrong with my implementation? I don't want the 'error' alert displayed, and the alert appears to be wrong because the app runs fine and the QRCode is still generated perfectly.

I've included a screen shot of the 'error' alert (it was hard to snap a screen shot because it as on the screen for such a short amount of time).

QRCode generation 'error'

QR Generation Code:

private Bitmap encodeAsBitmap(String str) throws WriterException {

    try {
        result = new MultiFormatWriter().encode(str, BarcodeFormat.QR_CODE, width, height, null);
    } catch (IllegalArgumentException iae) {
        // Unsupported format
        return null;
    }

    int width = result.getWidth();
    int height = result.getHeight();
    int[] pixels = new int[width * height];
    for (int y = 0; y < height; y++) {
        int offset = y * width;
        for (int x = 0; x < width; x++) {
            pixels[offset + x] = result.get(x, y) ? BLACK : WHITE;
        }
    }

    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
    return bitmap;
}

Update: I followed this SO post to help with the generation: QRCode Generation.

Community
  • 1
  • 1
Sakiboy
  • 7,252
  • 7
  • 52
  • 69
  • @MarcinOrlowski, that's not a very constructive comment. Please excuse me for trying to ask if anyone else has experienced this issue, I'd like to know if this is a bug or if I've done something wrong before I do go with something else... – Sakiboy Nov 18 '15 at 17:58
  • You can try to use these [codes](http://stackoverflow.com/a/14207326/4186942) to generate a barcode via zxing. Also, it might be a internal bug and you can report here:https://github.com/zxing/zxing/issues – bjiang Nov 18 '15 at 23:24
  • @bjiang, I'm using pretty much that same method. So I'm kind of thinking that it might actually be an internal bug. I'll look into things a little bit more before submitting a bug report. Thank you :) – Sakiboy Nov 19 '15 at 03:01
  • No problem, glad to help:) – bjiang Nov 19 '15 at 04:13
  • Apparently the error alert does not affect the ZXing library. So it's safe to use. – Sakiboy Nov 19 '15 at 17:19

1 Answers1

0

The error alert is part of the Android barcode service, it doesn't affect the ZXing app/library, so there's nothing to worry about.

Sakiboy
  • 7,252
  • 7
  • 52
  • 69