I need to create a qrcode in my android application, and I need a library or source code that lets me create a QR Code in an Android app.
The library I need must:
- not leave a watermark (like
onbarcode
library) - not use web service API to create the qrcode (like Google's library zxing)
- not need 3rd party installers (like QR Droid)
I already created such code for iPhone (Objective-C) but I need a quick fix for Android until I have time to make a QR Code generator of my own. It's my first android project so any help will be appreciated.
with zxing this is my code for create QR
Maybe this old topic but i found this library is very helpful and easy to use
QRGen
example for using it in android
I used zxing-1.3 jar and I had to make some changes implementing code from other answers, so I will leave my solution for others. I did the following:
1) find zxing-1.3.jar, download it and add in properties (add external jar).
2) in my activity layout add ImageView and name it (in my example it was tnsd_iv_qr).
3) include code in my activity to create qr image (in this example I was creating QR for bitcoin payments):
If someone is wondering, variable "btc_acc_adress" is a String (with BTC adress), amountBTC is a double, with, of course, transaction amount.
zxing does not (only) provide a web API; really, that is Google providing the API, from source code that was later open-sourced in the project.
As Rob says here you can use the Java source code for the QR code encoder to create a raw barcode and then render it as a Bitmap.
I can offer an easier way still. You can call Barcode Scanner by Intent to encode a barcode. You need just a few lines of code, and two classes from the project, under
android-integration
. The main one is IntentIntegrator. Just callshareText()
.Here is my simple and working function to generate a Bitmap! I Use ZXing1.3.jar only! I've also set Correction Level to High!
PS: x and y are reversed, it's normal, because bitMatrix reverse x and y. This code works perfectly with a square image.
EDIT
It's faster to use bitmap.setPixels(...) with a pixel int array instead of bitmap.setPixel one by one:
Have you looked into ZXING? I've been using it successfully to create barcodes. You can see a full working example in the bitcoin application src