QR code扫描仪 [英] QR code scanner
本文介绍了QR code扫描仪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的应用程序创建一个QR code扫描仪。
I would like to create a QR code scanner in my app.
我通过zxing去了,但我无法理解。我感兴趣的QR codeS而已。
I went through the zxing ,but I could not understand it. I am interested in QR codes only.
所有帮助是非常AP preciated。
All help is highly appreciated.
推荐答案
将com.google.zxing.client的副本。*源码包到项目中。您可以启动zxing扫描活动是这样的:
Place a copy of the com.google.zxing.client.* source packages into your project. You can start the zxing scanning activity like this:
Intent intent = new Intent(this, CaptureActivity.class);
startActivityForResult(intent, 0);
在你调用CaptureActivity中您可以处理结果时,扫描具有以下onActivityResult方法完成同样的活动:
In the same activity that you invoked the CaptureActivity in you can handle the result when the scan completes with the following onActivityResult method:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) {
String response = data.getAction();
if(Pattern.matches("[0-9]{1,13}", response)) {
// response is a UPC code, fetch product meta data
// using Google Products API, Best Buy Remix, etc.
} else {
// QR codes - phone #, url, location, email, etc.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(response));
startActivity(intent);
}
}
}
希望这有助于。
Hope this helps.
这篇关于QR code扫描仪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文