(1)下载二维码的库源码
链接:http://pan.baidu.com/s/1pKQyw2n 密码:r5bv
下载完成后打开可以看到 libzxing 的文件夹,最后添加进 Android Studio,操作 :File------》New-----》Import Moudle
(2)按钮单击事件为 scanner
后台代码:
public void scanner(View view){
startActivityForResult(new Intent(ScanActivity.this,
CaptureActivity.class),0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK){
Bundle bundle = data.getExtras();
String result= bundle.getString("result");
etCan.setText(result);
}
}
(3)若是需要连续扫描
后台代码:
链接:http://pan.baidu.com/s/1sle7v4L 密码:o85e