您的位置:首页 > 移动开发 > Android开发

源码项目Android 使用Zxing2.1 来读取二维码

2013-04-23 19:58 429 查看
废话就不多说了,开始。。。

【道谢参考】: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);
}


6、在 com.bbcvison.zxing.test.MainActivity.onActivityResult 中停止对读到的二维码停止理处

附件:(刚刚上传功成,但是我在我的资源面里没有找到响应的接连,回首再来编辑这里)

CaptureActivity.rar 是我生成的libproject

CaptureActivityTest.rar 是我的演示程序

再次感激:http://mukeshyadav4u.blogspot.com/2012/06/integrating-zxing-qr-code-scanner-into.html

[全文完]

文章结束给大家分享下程序员的一些笑话语录:

这年头的互联网真是娱乐了中国,网民们从各种各样的“门”里钻来钻去,又有好多“哥”好多“帝”,值得大家品味不已……网络经典语录,关于IT与互联网,经典与您分享!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: