1

I have been trying to generate a QR code using Zxing. Following the minimal instructions available on the Zxing project site, I was not able to get this integrated into my application. I have tried following this answer here (as well as many other search results), but BufferedImage does not seem to be available in the Android SDK. In short, Zxing is not playing nice with my application, or the documentation is not fully explaining the process properly.

I am looking for a simple way to pass in a string and generate a QR code image representing the string. Ant code samples, or even a nudge in the right direction would greatly appreciated.

Community
  • 1
  • 1
Mike D
  • 4,938
  • 6
  • 43
  • 99
  • `QRCodeEncoder` method `encodeAsBitmap` doesn't work for you? – Dan S Feb 28 '12 at 18:22
  • @DanS The QRCodeEncoder requires a reference to an activity and an intent. I was hoping to keep it simpler than that. – Mike D Feb 28 '12 at 19:09
  • The source is available could you just extract what you need? – Dan S Feb 28 '12 at 19:24
  • 1
    Are you opposed to needing internet? Google charts has a rest API that will accept a string and serve you a QR png. – FoamyGuy Feb 28 '12 at 19:54
  • @Tim Its not my first choice, the api requires building form to send. I would rather do it on the device. – Mike D Feb 28 '12 at 20:00

2 Answers2

2

I created an application at one point that needed to be able to generate a QR also.

I, like you started with trying to use ZXing to do it. The project is definitely capable of generating the QR image, but I was never able to get it working correctly.

The only integration they offer for QR generating is thru intents, and it just spits your QR into its own blank Activity.

I tried pulling out enough of the project that I'd be able to use the generator classes, but I could never get it working properly.

In the end I decided to go with the google charts api. Since it requires network it wasn't an ideal solution for me, but it was far easier / less complicated, and I was able to actually get it to work.

Edit:

Since the time of this post I have created a sample project that demonstrates how to download and show QR codes using the Google Image Charts API. The sample project can be located here: https://github.com/FoamyGuy/QRMaker. I hope it can help someone.

FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
  • I think thats where I'm heading, but I don't think my boss will like it, since, first glance, it doesn't support https, and there potentially identifiable information that is being encoded. – Mike D Feb 28 '12 at 20:30
1

I've been through the frustration of trying to integrate the ZXing library into my code and get rid of the need of having to install the third-party application. I finally got it to work.

You need to add the core.jar file from the latest ZXing release source to your project. You also need to add two more classes to your package to get it to work.

Just follow this step-by-step guide.

Community
  • 1
  • 1
Sam
  • 11,799
  • 9
  • 49
  • 68