android - 如何在 Android 中显示来自字符串的一维条形码?

标签 android barcode barcode-scanner zxing

我正在使用 ZXing via intent 来扫描一维条形码。 ZXing 将扫描的一维条码类型(UPC-A、Code 39 等)和条码中编码的字符串发回给我。我想获取一维条形码的类型和字符串以及生成和图像,并将其显示在 Activity 的 ImageView 中。

我也愿意使用类似于“Free 3 of 9”的字体在 TextView 中显示条形码,但我不知道该怎么做。

我注意到 ZXing 中有一个名为 EncodeActivity 的 Activity 可以执行我需要的操作,但仅限于二维码。

如有任何帮助,我们将不胜感激。

谢谢。

最佳答案

使用 ZXing IntentIntegratorIntentResult 类!

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

它只有在你的 Android 上安装了 Barcode reader 时才有效

如果你需要帮助,尽管问我!

关于android - 如何在 Android 中显示来自字符串的一维条形码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4865597/

相关文章:

java - 如何录制音频,以使其在达到特定长度后覆盖录制的开始?

iphone - 如何使用phonegap 编译适用于iPhone 的条码扫描仪?

ios - 有没有办法使用 Apple 内置的 iOS 条码 API 扫描 5 位附加条码?

android - 程序流程 AppInventor

android - 当输入语言 android 设备是波斯语时,从数据库或文件读取的整数或长值变成波斯数字?

android - 链接源未在MediaPlayer或SoundPool中播放

android - 调试这个的好策略?

algorithm - QR 编码器/解码器支持 GS1?

storage - 二维条码最大存储能力

javascript - jQuery:监听来自键盘的自动扫描仪输入?