简单的二维码识别(实现代码)

一、倒依赖

//二维码识别
    compile 'com.acker:simplezxing:1.5'

二、在Activity的Xml中

三、在Activity中

 @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.mBtn:
                startActivityForResult(new Intent(getContext(), CaptureActivity.class), CaptureActivity.REQ_CODE);

                break;
        }
    }
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        String s = CaptureActivity.EXTRA_SCAN_RESULT;
        text = data.getStringExtra(s);
        //mText.setText(text);

        Intent intent = new Intent(getContext(), Main2Activity.class);
        intent.putExtra("uri", text);
        startActivity(intent);
    }

 

你可能感兴趣的:(简单的二维码识别(实现代码))