如何在Android的ZXing API集成有前置摄像头? [英] How to integrate ZXing api with front camera in android?

查看:1142
本文介绍了如何在Android的ZXing API集成有前置摄像头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想在我的Andr​​oid应用程序集成ZXing API,但无法找到适当的文件。

I just wanted to integrate ZXing API in my android app, but cant find the proper documentation.

推荐答案

按照以下步骤操作:

1)下载源$ C ​​$ C在这里:<一href="http://$c$c.google.com/p/zxing/source/checkout">http://$c$c.google.com/p/zxing/source/checkout

1) Download the source code here: http://code.google.com/p/zxing/source/checkout

2)导入源$ C ​​$ C作为新的项目到Eclipse中,使该项目的根目录中的文件夹/机器人(源$ C ​​$ C中)。

2) Import the source code as a new project into Eclipse and make the root of the project be the folder /android (found in the source code).

3)确保也在/核心/ src中所有内容复制到该项目,为源$ C ​​$ C导入的步骤2需要它。

3) Make sure to also copy everything under /core/src to this project, as the source code imported on step 2 requires it.

4)请务必设置您的编译器的Java 1.6的Eclipse(右键点击你的项目,属性,Java编译器),否则你将得到有关@Override注释的一些错误。

4) Make sure to set your compiler to Java 1.6 on Eclipse (right click on your project, properties, Java Compiler) otherwise you will get some errors regarding the @Override annotation.

5)编辑类com.google.zxing.client.android.camera.open.GingerbreadOpenCameraInterface如下:

5) Edit the class com.google.zxing.client.android.camera.open.GingerbreadOpenCameraInterface as follows:

  while (index < numCameras) {
       Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
       Camera.getCameraInfo(index, cameraInfo);


       if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
           break;
       }
       /*//Original code (gets the back camera. This is NOT what you want!)
       if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
    break;
  }*/
  index++;
}

5),使这个项目作为一个库,很容易说明如下:<一href="http://developer.android.com/tools/projects/projects-eclipse.html#SettingUpLibraryProject">http://developer.android.com/tools/projects/projects-eclipse.html#SettingUpLibraryProject

6)本项目引用到你的实际项目(右击你的实际项目,属性,Java构建路径,项目,添加)。

6) Reference this project into your real project (right click on your real project, properties, Java Build Path, Projects, Add).

7)大功告成! =)

7) You're done! =)

希望它帮助。

这篇关于如何在Android的ZXing API集成有前置摄像头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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