如何在Android的ZXing API集成有前置摄像头?摄像头、如何在、ZXing、Android

由网友(心口的朱砂痣)分享简介:我只是想在我的Andr​​oid应用程序集成ZXing API,但无法找到适当的文件。I just wanted to integrate ZXing API in my android app, but cant find the proper documentation.推荐答案按照以下步骤操作:1)下载源$...

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

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

推荐答案

按照以下步骤操作:

1)下载源$ C ​​$ C在这里: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),使这个项目作为一个库,很容易说明如下: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! =)

希望它帮助。

阅读全文

相关推荐

最新文章