【问题标题】:Barcode decoding in android-phonegap appandroid-phonegap 应用程序中的条码解码
【发布时间】:2013-08-20 22:31:11
【问题描述】:

我正在开发一个 android-phonegap 应用程序,我必须在其中解码我的学生证条码和图书馆图书的条码。首先,我必须通过连接到应用程序的移动摄像头捕获条码。 这是我写的.js代码

scancode.js

    window.plugins.barcodeScanner.scan(function(result) {

    alert("We got a barcode\n" +
             "Result: " + result.text + "\n" +
             "Format: " + result.format + "\n" + 
              "Cancelled: " + result.cancelled);

    }, function(error) {  

    alert("Scanning failed: " + error);
    }
    );

这是我获取条形码详细信息的 html 文件

burrow.html

    <!DOCTYPE html>

    <html>

    <head>
    <title>Burrow</title>

<script type="text/javascript" charset="utf-8" src="cordova-2.7.0.js"></script>
<script type="text/javascript" charset="utf-8" src="PopUpBox.js"></script>
<script type="text/javascript" src="Connect.js"></script>
<script type="text/javascript" src="BarCode.js"></script>

    </head>
    <form>
    <body>
    <FORM>
     <INPUT Type="button" style="background-color:#4682B4" VALUE="Back" onClick="history.go(-1);return true;">

    </FORM>
    <br><br>
    <img src="../www/images/pic.jpg" style="width:300px;height:80px;">
    <br><br><br>


<center><input type="button" style="background-color:#2F4F4F;width:230px;height:45px;text-align:center;color:#DCDCDC;font-size:1.5em" onClick="window.plugins.barcodeScanner.scan( function(result)" value="Scan Student ID"></center>
 <br>
 <center><input type="button" style="background-color:#2F4F4F;width:230px;height:45px;text-align:center;color:#DCDCDC;font-size:1.5em" onClick="window.plugins.barcodeScanner.scan( function(result)" value="Scan Book ID"></center>

 <br><br>
<center><input type="button" style="background-color:#2F4F4F;width:230px;height:45px;text-align:center;color:#DCDCDC;font-size:1.5em" onClick="Burrow_Confirmation()" value="Burrow"></center><br/>
    </body>
    </form>
    </html>

我根据文档创建了条码扫描器库。我的编码不起作用。你能给出解决方案吗??

【问题讨论】:

  • 你添加插件到config.xml了吗?
  • 是的 :( 你认为这不是编码的错误吗???
  • 您是否在某处包含您的scancode.js 文件? “我的编码不起作用”是什么意思?您能否提供一些错误消息和所发生情况的描述?

标签: android html css cordova


【解决方案1】:

对于条形码扫描仪,我使用了这个插件https://github.com/wildabeast/BarcodeScanner。它必须与您使用的相同。如果是这样,请确保已将 zxing 项目添加到 eclipse 中并在项目中引用它,并将必要的 zxing 活动设置添加到应用程序清单文件中。检查此链接中提供的信息https://github.com/phonegap/phonegap-plugins/tree/master/Android/BarcodeScanner

【讨论】:

  • 是的,我用过。而且我已经完成了你提供的链接中提到的所有内容。你能给我一个示例代码,说明如何在我的编码中使用这个库来获取条形码如果可以解码?
  • 您是否收到任何特定错误。是什么不工作?
  • 我没有收到任何错误。但是我收到了一些警告。而且我无法在模拟器中运行该应用程序。它仅在与条形码扫描仪库连接后发生
  • Barcodescanner 无法在模拟器中工作,因为它需要硬件摄像头。尝试在设备上测试它
  • 条码扫描部分现在工作正常。我还需要向我的应用程序推送通知。我正在使用谷歌 api,我已经完成了以下链接 devgirl.org/2013/07/17/… 中的所有事情,但是在运行时我没有收到该教程中所说的警报框。它在控制台安装错误中给出以下错误:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-11
  • 1970-01-01
相关资源
最近更新 更多