zbar扫描快,zxing可以生成和识别本地,So,我就把他们结合在了一起
WechatIMG25.png
startActivityForResult(new Intent(getApplicationContext(), QRActivity.class), FunctionConfig.REQUEST_CAMERA); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == FunctionConfig.REQUEST_CAMERA) { Log.e(TAG, "onActivityResult: " + data.getStringExtra("QRcontent")); Toast.makeText(getApplicationContext(), data.getStringExtra("QRcontent"), Toast.LENGTH_SHORT).show(); } } }
OK,就这么简单!
Bitmap qrCode = QRUtils.getInstance().createQRCode("www.qq.com");
//可以传图片路径,Bitmap,ImageView 是不是很人性化String s = QRUtils.getInstance().decodeQRcode(iv_qr);
Github:https://github.com/bertsir/zBarLibary