Zbar扫描仪错误java.lang.RuntimeException:cancelAutoFocus失败

问题描述 投票:0回答:1

我的应用程序包含条形码扫描仪,我使用了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);

}
java android xml barcode zbar
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.