2012-01-11 95 views
1

我正在上的QR碼閱讀器應用程序,按鈕單擊我已經打開了攝像機視圖。 然後依靠他們的結果會轉到下一屏幕,但第二次,當我打開它給我的錯誤CamController屏幕:獲得資源失敗:_camConfigHandle無效黑莓錯誤_camConfigHandle無效

編輯: 我試試這個代碼刪除掃描儀和移動到下一個屏幕

UiApplication.getUiApplication().invokeLater(new Runnable() { 
          public void run() { 
           try { 
            _scanner.getPlayer().stop(); 

           } catch (MediaException e) { 
            e.printStackTrace(); 
           } 
           _scanner.getPlayer().close(); 
           System.out.println("closeScan"); 
           _scanner.getPlayer().deallocate(); 
           System.out.println("deallocateScan"); 
           System.out.println("deleteAllScan"); 
           UiApplication.getUiApplication().popScreen(_barcodeScreen); 
          } 
         }); 

,這是我的代碼掃描

private void scanBarcode() { 

     if (_barcodeScreen == null) { 
      Hashtable hints = new Hashtable(); 
      Vector formats = new Vector(); 
      formats.addElement(BarcodeFormat.QR_CODE); 
      hints.put(DecodeHintType.POSSIBLE_FORMATS, formats); 
      hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); 
      BarcodeDecoder decoder = new BarcodeDecoder(hints); 
      try { 
       _scanner = new BarcodeScanner(decoder, new MyBarcodeDecoderListener()); 
       _barcodeScreen = new MyBarcodeScannerViewScreen(_scanner); 

      } catch (Exception e) { 
      System.out.println("error="+e.toString()); 
       return; 
      } 
     } 

     try { 
      _scanner.startScan(); 
      UiApplication.getUiApplication().pushScreen(_barcodeScreen); 
     } catch (Exception e) { 
      System.out.println("error1="+e.toString()); 
     } 

    } 

在此先感謝。

+0

請張貼一些代碼。這將更容易幫助你, – 2012-01-11 13:49:58

+0

我有更新的問題 – 2012-01-12 08:24:26

回答

1

你關閉相機正確?請使用以下方法並使其適合做類似的事情以正確關閉相機

//close the scanner 
public void closeScanner() 
{ 
if (this.player != null) { 
    try { 
    this.player.stop(); 
    } catch (MediaException e) { 
     //handle exception 
    Log.Error("Exception stopping player: " + e); 
    } 
    //de allocate and close player 
    this.player.deallocate(); 
    this.player.close(); 
} 
}