簡體   English   中英

Zbar 掃描儀錯誤 java.lang.RuntimeException:cancelAutoFocus 失敗

[英]Zbar Scanner Error java.lang.RuntimeException: cancelAutoFocus failed

我的應用程序包含條形碼掃描儀,我使用了 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()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM