gpt4 book ai didi

android - zxing扫描二维码后相机卡住

转载 作者:太空狗 更新时间:2023-10-29 16:30:36 27 4
gpt4 key购买 nike

我使用结果处理程序实现了二维码扫描器。它扫描得很好。但是,在第一次扫描完成后,相机卡住了。如何实现二维码扫码让摄像头持续扫码不卡顿?

我的代码是这样的:

public class SimpleScannerFragment extends Fragment implements ZXingScannerView.ResultHandler {


private ZXingScannerView mScannerView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.scannerview, null);
mScannerView = (ZXingScannerView) v.findViewById(R.id.scanner_view);
return v;
}

@Override
public void onResume() {

super.onResume();
mScannerView.startCamera();
mScannerView.setResultHandler(this);

}


@Override
public void handleResult(Result rawResult) {
ParsedResult parserdResult = ResultParser.parseResult(rawResult);


Toast.makeText(getActivity(), "Contents = " + rawResult.getText() + ", Format = " + rawResult.getBarcodeFormat().toString(), Toast.LENGTH_SHORT).show();
}

@Override
public void onPause() {
super.onPause();
mScannerView.stopCamera();

}
}

最佳答案

根据手册(https://github.com/dm77/barcodescanner)只需在处理程序中恢复您的摄像头:

  @Override
public void handleResult(Result rawResult) {
ParsedResult parserdResult = ResultParser.parseResult(rawResult);
Toast.makeText(getActivity(), "Contents = " + rawResult.getText() + ", Format = " + rawResult.getBarcodeFormat().toString(), Toast.LENGTH_SHORT).show();
mScannerView.resumeCameraPreview(this);
}

关于android - zxing扫描二维码后相机卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39970983/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com