ss.sao.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { QRCodeManager.getInstance() .with(getActivity()) .setReqeustType(1) .scanningQRCode(new OnQRCodeScanCallback() { @Override public void onCompleted(String result) { Toast.makeText(getActivity(), "结果:" + result, Toast.LENGTH_SHORT).show(); } @Override public void onError(Throwable errorMsg) { Toast.makeText(getActivity(), "扫描错误"+errorMsg.toString(),Toast.LENGTH_SHORT).show(); } @Override public void onCancel() { Toast.makeText(getActivity(), "扫描任务取消了", Toast.LENGTH_SHORT).show(); } });