【问题标题】:How do i get the UPC code from barcode scanner?如何从条码扫描仪获取 UPC 代码?
【发布时间】:2012-03-10 00:26:40
【问题描述】:

我是新来的堆栈溢出,虽然我已经阅读了很长一段时间的 PHP 和一些我遇到的 android 问题。

我的问题是如何从条形码扫描仪获取数据(仅 UPC 代码和图像),以便将其插入 MySQL 表中?

我会自己解决 MySQL 表插入问题,但这简直要了我的命!我对 android 应用程序等还很陌生,但我非常决心将我的想法付诸实践并开始在市场上销售。到目前为止,由于我在他们的 WIKI 上看到的 Zxing 的 URL http://zxing.appspot.com/scan

,我能够启动扫描程序

点击我的应用程序中的按钮即可启动扫描仪。它可以读取并且可以工作,但我不知道如何从结果中获取数据。

我查看了该文章...

`public void onActivityResult(int requestCode, int resultCode, Intent intent) {
  IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode,    resultCode,         intent);
  if (scanResult != null) {
    // handle scan result
  }
  // else continue with any other code you need in the method
  ...
}`    

还有我把这段代码放在哪里?

`IntentIntegrator integrator = new IntentIntegrator(yourActivity);
integrator.initiateScan();`

【问题讨论】:

  • 条码扫描器是一种什么样的设备?比如USB还是蓝牙HID?
  • @DanS zxing 是一个使用手机摄像头扫描条形码的库。
  • 哦,我以为你指的是物理设备。
  • 我正在尝试扫描条形码,然后使用 zxing 的库通过 UPC 查找产品,然后直接复制结果(图像和 UPC 代码,当然还有项目名称)

标签: android barcode barcode-scanner zxing


【解决方案1】:

查看 ZXing Google 代码页面中的 Scanning via Intent 文章。有关如何处理来自 ZXing 扫描活动的返回值的信息

【讨论】:

  • 我已经查看了那篇文章...我知道我需要将代码插入到不同的位置,但是在该文章页面上,将其放入您的活动中意味着什么? public void onActivityResult(int requestCode, int resultCode, Intent intent) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanResult != null) // 处理扫描结果 } // else 继续使用方法中需要的任何其他代码... }
【解决方案2】:
 IntentIntegrator integrator = new IntentIntegrator(yourActivity);
 integrator.initiateScan();

这个代码是你需要调用scanner的地方...例如,如果你有一个按钮,你可以把这行放到它的OnClickListener中。

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode,    resultCode,         intent);
if (scanResult != null) {
// handle scan result
}
 // else continue with any other code you need in the method
...
 }

这个应该存在于你的应用中,作为一种方法......

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多