扫描二维码 获取内容为字符串

//点击跳转到扫描二维码界面

start.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
textView.setText("");
Intent intent  = new Intent(MainActivity.this,CaptureActivity.class);
startActivityForResult(intent,REQUESTCODE);
}

});


//处理扫描后的结果

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);


Log.d(TAG, "onActivityResult() returned: " + "接收结果.....");


if (resultCode==RESULT_OK){
Log.d(TAG, "onActivityResult() returned: " + "返回成功");
Bundle bundle = data.getExtras();
String result = bundle.getString("result");
textView.setText(result);
Log.d(TAG,"----"+result+"---");
}


}


你可能感兴趣的:(扫描二维码 获取内容为字符串)