gpt4 book ai didi

java - Zbar 扫描仪错误 java.lang.RuntimeException : cancelAutoFocus failed

转载 作者:行者123 更新时间:2023-12-01 16:28:18 31 4
gpt4 key购买 nike

我的应用程序包含条形码扫描仪,我使用了 Zbar 扫描仪,它可以工作,但不断出现以下错误,我搜索了很多,但没有找到任何解决方案错误:

java.lang.RuntimeException: cancelAutoFocus failed
java.lang.RuntimeException: cancelAutoFocus failed
at android.hardware.Camera.native_cancelAutoFocus(Native Method)

我使用的代码:

private void initScanner(){
mScannerView = new ZBarScannerView(this);
scannView.addView(mScannerView);
mScannerView.setResultHandler(this);
mScannerView.startCamera();
mScannerView.setAutoFocus(true);
mScannerView.setSoundEffectsEnabled(true);
mScannerView.setContentDescription("barcode scanner ");
//scanResult.setText("scan barcode automatically");
mScannerView.setClickable(true);

}

    @Override
public void handleResult(me.dm7.barcodescanner.zbar.Result rawResult) {
nameOfInputItems.requestFocus();
ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
tg.startTone(ToneGenerator.TONE_PROP_BEEP);
// nameOfInputItems.requestFocus();

if (rawResult != null) {
if (rawResult.getContents() == null) {
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "done!", Toast.LENGTH_LONG).show();
scanResult.setText(rawResult.getContents());
barCode=scanResult.getText().toString();

}
} mScannerView.resumeCameraPreview(this);

}

最佳答案

我在代码中发现了问题我应该从 onResume 方法中删除 mScannerView.startCamera()

关于java - Zbar 扫描仪错误 java.lang.RuntimeException : cancelAutoFocus failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62116926/

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