Phonegap BarcodeScanner插件可以在Android项目中使用 [英] Phonegap BarcodeScanner plugin could work in Android project

查看:78
本文介绍了Phonegap BarcodeScanner插件可以在Android项目中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将BarcodeScanner插件集成到我的Android Phonegap项目之一. 我什至已经按照github提供的教程的步骤来做所有事情.

I have tried to integrate the BarcodeScanner plugin to one of my Phonegap project of Android. I have even done all the thing step by step as the tutorial provided by github.

已导入库,已导入BarcodeScanner.java文件,

The library has been imported,BarcodeScanner.java file has been imported,

barcode.js已导入,

barcode.js has been imported,

活动已添加到AndroidManifest.xml

activity has been added to AndroidManifest.xml

res路径中的config.xml也已修改.

the config.xml in res path has been also modified.

当我使用Eclipse测试我的应用程序时,出现以下错误.

When I test my app with eclipse, I have gotten the error below.

顺便说一句,我使用了phonegap 2.9,使用该插件的代码如下.

By the way, I have used phonegap 2.9 and my code for using the plugin is as below.

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

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

Really do not know what to do. Could you please give me any suggestion?

谢谢.

推荐答案

最后,我解决了.这是因为Phonegap的版本.该版本应高于3.0.

Finally, I work out it. It is because of Phonegap's version. The version should be above 3.0.

这篇关于Phonegap BarcodeScanner插件可以在Android项目中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆