Sameer Zinzuwadia
Sameer Zinzuwadia

Reputation: 3285

Blackberry error _camConfigHandle is invalid

I am making the qr-code reader app,on button click i have opened the camera view. Then depend on their result it will navigate to next screen but second time when i open the screen it gives me the error CamController:get res failed: _camConfigHandle is invalid.

EDITED: I have try this code for remove the scanner and move to next screen

 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);
                            }
                        });

and this is my code to scan

 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());
        }

    }

Thanks in Advance.

Upvotes: 1

Views: 130

Answers (1)

rfsk2010
rfsk2010

Reputation: 8611

Are you closing the camera properly? please use the following method and adapt it to do similar things to close the camera properly

//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();
}
}

Upvotes: 1

Related Questions