Phonegap BarcodeScanner插件可以在Android项目中使用

时间:2013-11-01 07:43:11

标签: cordova phonegap-plugins barcode-scanner

我尝试将BarcodeScanner插件集成到Android的Phonegap项目中。 我甚至一步一步地完成了由github提供的the tutorial

已导入库,已导入BarcodeScanner.java文件, enter image description here

已导入barcode.js, enter image description here

活动已添加到AndroidManifest.xml

res路径中的config.xml也已被修改。 enter image description here

当我用eclipse测试我的应用程序时,我收到了以下错误。 enter image description here

顺便说一句,我使用过phonegap 2.9,我使用该插件的代码如下所示。

document.addEventListener("deviceready", deviceReady, true);

    function deviceReady() {
        var scanner = window.plugins.barcodeScanner;//note that cordova.plugins.barcodeScanner has also been tried. Same error.
        scanner.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);
            });
    }

真的不知道该怎么办。你能给我任何建议吗?

提前致谢。

1 个答案:

答案 0 :(得分:1)

最后,我解决了这个问题。这是因为Phonegap的版本。版本应高于3.0。