IBM Mobilefirst 7.0-混合应用程序的条形码扫描器无法正常工作

时间:2015-06-01 13:55:52

标签: android ibm-mobilefirst

在这里,我正在尝试使用IBM Mobilefirst构建混合应用程序,我想在其中使用条形码扫描程序。为此,我按照以下链接。

https://www.ibm.com/developerworks/community/blogs/WASFAQs/entry/using_a_barcode_scanner_with_worklight?lang=en

而且,这是我的index.html:

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Barcode</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
        <!--
            <link rel="shortcut icon" href="images/favicon.png">
            <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> 
        -->
        <link rel="stylesheet" href="css/main.css">
        <script>window.$ = window.jQuery = WLJQ;</script>
<script>
$('#scanButton').bind('click', doScan);
function doScan(){
alert("Hello");
alert(cordova.exec(onScanSuccess, onScanFailure, 'BarcodeScanner', 'scan', []));
}
function onScanSuccess(result) {
alert("We got a barcode\n" +
    "Result: " + result.text + "\n" +
    "Format: " + result.format + "\n" +
    "Cancelled: " + result.cancelled);
}
function onScanFailure(error) {
alert("Scanning failed: " + error);
}
</script>
    </head>
    <body style="display: none;">
        <!--application UI goes here-->
        <script src="js/initOptions.js"></script>
        <script src="js/main.js"></script>
        <script src="js/messages.js"></script>
        <h1>Barcode scanner</h1>
        <button type="button" id="scanButton" >Scan</button>
    </body>
</html>

1 个答案:

答案 0 :(得分:1)

cordova.exec失败的主要原因是你错误地使用插件引用配置了config.xml。

您没有将LogCat日志添加到您的问题中 - 您会看到您遇到的实际错误。