使用Zxing实现扫二维码描

1.集成Zxing.bar

2.复制代码到项目中

 

QQ图片20151127104221

3.修改 MipacActivityCapture.java  的扫描结果方法 handleDecode()

 

/**
     * 处理扫描结果,实现活动页面跳转
     * @param result
     * @param barcode
     */
    public void handleDecode(Result result, Bitmap barcode) {
        inactivityTimer.onActivity();
        playBeepSoundAndVibrate();
        String resultString = result.getText();
        if (resultString.equals("")) {
            Toast.makeText(MipcaActivityCapture.this, "Scan failed!", Toast.LENGTH_SHORT).show();
        }else {
            Intent resultIntent = new Intent(MipcaActivityCapture.this,NewsMainActivity.class);
            Bundle bundle = new Bundle();
    
            bundle.putString("result", resultString);
            bundle.putParcelable("bitmap", barcode);
        
            resultIntent.putExtras(bundle);
            //this.setResult(RESULT_OK, resultIntent);
            startActivity(resultIntent);
        }
        MipcaActivityCapture.this.finish();
    }
posted @ 2015-11-27 12:31  Pace千雨  阅读(582)  评论(0编辑  收藏  举报