I just wanted to integrate ZXing API in my android app, but cant find the proper documentation.
Follow these steps:
1) Download the source code here: http://code.google.com/p/zxing/source/checkout
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) Make sure to also copy everything under /core/src to this project, as the source code imported on step 2 requires it.
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) 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) Make this project as a library, as easily described here: http://developer.android.com/tools/projects/projects-eclipse.html#SettingUpLibraryProject
6) Reference this project into your real project (right click on your real project, properties, Java Build Path, Projects, Add).
7) You're done! =)
Hope it helps.
The latest version of Barcode Scanner as well as the ZXing source code now supports front facing camera.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With