开发者

How to display a 1-D barcode from string in Android?

开发者 https://www.devze.com 2023-02-07 18:49 出处:网络
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

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 an开发者_JAVA技巧d 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.


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!


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消