简体   繁体   English

使用Android Studio扫描Google Glass中的条形码

[英]Scan the barcode in Google glass using Android Studio

I am using Android Studio as an IDE to develop the Google Glass Application. 我使用Android Studio作为IDE来开发Google Glass应用程序。

Here is the code I am using: 这是我正在使用的代码:

Intent intent = new Intent(context, com.google.zxing.client.android.CaptureActivity.class);

But it gives the error saying cannot resolve symbol 'android'. 但是它给出了错误,提示无法解析符号“ android”。

I have added the Gradle dependency as below: 我添加了Gradle依赖项,如下所示:

compile 'com.google.zxing:core:2.3.0'

Because of this, I cannot run the project. 因此,我无法运行该项目。 Please let me know what can be done to resolve the issue. 请让我知道可以解决此问题的方法。 Also if any other or better alternative is available, please let me know. 另外,如果还有其他更好的选择,请告诉我。

Since you are just including the ZXing core you won't have any of the Android code for ZXing. 由于您仅包含ZXing核心,因此不会有任何ZXing的Android代码。

Take a look at BarcodeEye: https://github.com/BarcodeEye/BarcodeEye 看看BarcodeEye: https//github.com/BarcodeEye/BarcodeEye

Adding core won't do anything if you are integrating by Intent . 如果通过Intent进行集成,则添加core不会执行任何操作。 You need android-integration , if anything, to use IntentIntegrator . 您需要android-integration才能使用IntentIntegrator Starting the Intent as you show won't quite work. 如您所展示的那样启动Intent不太可行。 Also, you should use a much newer version -- 3.1.0, not 2.3.0. 另外,您应该使用更新的版本-3.1.0,而不是2.3.0。 Finally you need to build and install the Glass app, which is in the project at glass/ . 最后,您需要构建并安装Glass应用程序,该应用程序位于glass/中的项目中。 I have not tested it with Intent s but someone mentioned it works? 我没有使用Intent进行过测试,但是有人提到它可以工作吗?

For scanning bar codes I'm using zbar libraries. 为了扫描条形码,我正在使用zbar库。 I have downloaded and added the zbar.jar into the libs folder of my Android Studio Project and then added to the gradle dependencies like: 我已经下载了zbar.jar并将其添加到我的Android Studio项目的l​​ibs文件夹中,然后添加到了gradle依赖项中,例如:

dependencies {
    ....
    compile files('libs/zbar.jar')
} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM