Android(安卓)使用Zxing2.1 来读取二维码
16lz
2021-01-26
【鸣谢参考】:http://mukeshyadav4u.blogspot.com/2012/06/integrating-zxing-qr-code-scanner-into.html
用连接给的方法,发现在读成功之后没有返回,然后就看看了源码,得到原因是CaptureActivity是根据来源进行转发处理的,在intent中进行设置来源的Action就好了。
主要流程:
1、下载zxing的源码
用svn checkout http://zxing.googlecode.com/svn/trunk/源码
2、将android项目导入到eclipse中,并标记为libproject
3、创建自己的项目,并且应用第二部中的libprpoject
4、在自己的AndroidManifest.xml 中增加如下的内容:
<activity android:name="com.google.zxing.client.android.CaptureActivity" android:configChanges="orientation|keyboardHidden" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> --> <intent-filter> <action android:name="com.google.zxing.client.android.SCAN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>5、调用读二维码的服务
我是用一个button来进行演示的
public void scan(View view){Intent intent = new Intent(this,CaptureActivity.class);intent.setAction(Intents.Scan.ACTION);intent.putExtra(Intents.Scan.MODE, Intents.Scan.QR_CODE_MODE);intent.putExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS, 0L);startActivityForResult(intent, 0);}
附件: CaptureActivity.rar 是我生成的libproject CaptureActivityTest.rar 是我的演示程序 再次感谢:http://mukeshyadav4u.blogspot.com/2012/06/integrating-zxing-qr-code-scanner-into.html [全文完]
更多相关文章
- Android中视图View的深入理解及实例演示——以腾讯笔试题为例
- 【整理自慕课网】Android动感系列-扫一扫 ZXing
- Android通过PHP连接mysql(带源码)
- 【持续更新】Android(安卓)源码下载地点
- 【Android】一键清理后台实现【附源码】
- Android(安卓)Binder 驱动 - 内核驱动层源码分析
- Android(安卓)MediaPlayer源码分析总结
- Android系统版本与API等级对应关系表及各版本源码
- Android源码(9) --- Binder(3) AIDL使用