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).
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.