Android 集成 Zxing 条码扫描器

参考文章(需XX):http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/

本文在如上参考文章基础之上,进行了一些修改:

1. 修改扫描 action 的名字,当用户手机上已安装了 Zxing 扫描器,触发扫描操作不会弹出选择框(默认会弹出自己的应用程序和 Zxing 条码扫描器两个选项)

2. 兼容 Zxing 推荐的 IntentIntegrator,如果用户手机上安装了 Zxing 条码扫描器,优先使用安装的扫描器

step1. 签出Zxing源代码

svn checkout http://zxing.googlecode.com/svn/trunk/ zxing-read-only

step2. 编译Zxing源代码

cd zxing-read-only
ant -f core/build.xml

step3. 在Eclipse中导入Zxing的安卓工程

路径是 zxing-read-only/android,并设置它为一个 library 工程,右键工程属性 | Android | Is Library

step4. 修改源代码 CaptureActivity/src/com/google/zxing/client/android/Intents.java 第 34 行

// public static final String ACTION = "com.google.zxing.client.android.SCAN";
public static final String ACTION = "com.xxx.xxx.SCAN"; // 避免和默认的 Zxing 条码扫描器冲突
 修改源代码 CaptureActivity/src/com/google/zxing/client/android/camera/CameraConfigurationManager.java 第 101 行:

相关推荐