5

I am using ZXing via intent to scan 1D bar-codes. ZXing sends me back the type of 1D barcode that was scanned (UPC-A, Code 39, etc...) and the string that is encoded in the barcode. I would like to take the type and string and generate and image of the 1D barcode and display it in an ImageView in an activity.

I am also open to displaying the barcode in a TextView using a font similar to "Free 3 of 9", but I cannot figure out how to do this.

I noticed that there is an activity in ZXing called EncodeActivity that can perform what I need, but only for QR codes.

Any help would be appreciated.

Thanks.

Matt Wear
  • 1,211
  • 2
  • 15
  • 24
  • Could you solved?. I have to do the same and I can't understand how to do?? – Mark Comix Jul 26 '11 at 18:21
  • Nope, sorry, I had to generate it on the server and save the barcode image on the phone. I wasn't able to generate it on the phone. – Matt Wear Jul 26 '11 at 20:56
  • Try this one: http://barcode4j.sourceforge.net/index.html – Olegas Feb 01 '11 at 17:37
  • Thanks for the suggestion. I couldn't find an example on their site that did import something from awt though. – Matt Wear Feb 01 '11 at 19:53
  • Anyway, some implementation details can be taken from that library (encoding details, etc...) – Olegas Feb 01 '11 at 19:59
  • True, I've given you the point because that definitely is possible, but I was hoping to implement a solution that might take less effort. Thanks, but I'm still looking for an easier solution. – Matt Wear Feb 01 '11 at 20:05
  • If online variant is suitable you can try this one: http://www.bcgen.com/linear-barcode-creator.html – Olegas Feb 01 '11 at 20:15
  • Also, check this question: http://stackoverflow.com/questions/1700597/barcode-image-generator-in-java – Olegas Feb 01 '11 at 20:19
  • I couldn't get any of those to work. – Matt Wear Feb 07 '11 at 21:25

2 Answers2

4

Using ZXing IntentIntegrator and IntentResult classes!

    String data = "123456789";

    Intent intent = new Intent("com.google.zxing.client.android.ENCODE");  

    intent.addCategory(Intent.CATEGORY_DEFAULT); 

    intent.putExtra("ENCODE_FORMAT", "CODE_128");  

    intent.putExtra("ENCODE_DATA", data);  

    startActivity(intent); 

It only works if you have the Barcode reader installed on your Android

If you need help, ask me!

Dediqated
  • 901
  • 15
  • 35
Mark Comix
  • 1,878
  • 7
  • 28
  • 44
3

Display Barcode using Google barcode reader

Intent intent = new Intent("com.google.zxing.client.android.ENCODE");   
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.putExtra("ENCODE_TYPE", "TEXT_TYPE"); 
intent.putExtra("ENCODE_DATA",scan_code_main); // content part
intent.putExtra("ENCODE_FORMAT",scan_code_2); // format part

startActivity(intent);
nhahtdh
  • 55,989
  • 15
  • 126
  • 162
Utpal
  • 31
  • 1