2012-02-20 3 views
1

Я реализую сканер QR-кода для устройств Blackberry, и я использую библиотеки ZXing для этого. Кстати, для os 6+. Проблема, с которой я сталкиваюсь, заключается в том, что иногда, иногда, когда камера открывается для подготовки сканирования, устройство замерзает и выполняет полную перезагрузку ...Zxing qr scan blackberry crash

В противном случае он работает большую часть времени, я могу сканировать и декодировать коды qr и т. д. Однако кажется, что это иногда кажется, что он рушится без причины. Я не знаю, что-то с камерой или что-то в моем коде, но я предоставлю код.

public void scanBarcode() { 

    // First we create a hashtable to hold all of the hints that we can 
    // give the API about how we want to scan a barcode to improve speed 
    // and accuracy. 
    Hashtable hints = new Hashtable(); 

    // The first thing going in is a list of formats. We could look for 
    // more than one at a time, but it's much slower. 
    Vector formats = new Vector(); 
    formats.addElement(BarcodeFormat.QR_CODE); 
    hints.put(DecodeHintType.POSSIBLE_FORMATS, formats); 

    // We will also use the "TRY_HARDER" flag to make sure we get an 
    // accurate scan 
    hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); 

    // We create a new decoder using those hints 
    BarcodeDecoder decoder = new BarcodeDecoder(hints); 

    // Finally we can create the actual scanner with a decoder and a 
    // listener that will handle the data stored in the barcode. We put 
    // that in our view screen to handle the display. 
    try { 
     _scanner = new BarcodeScanner(decoder, new MyBarcodeDecoderListener()); 
     _barcodeScreen = new MyBarcodeScannerViewScreen(_scanner); 

    } catch (Exception e) { 
     return; 
    } 


    // If we get here, all the barcode scanning infrastructure should be set 
    // up, so all we have to do is start the scan and display the viewfinder 
    try { 
     _scanner.stopScan(); 
     _scanner.getPlayer().start(); 
     _scanner.startScan(); 
     UiApplication.getUiApplication().pushScreen(_barcodeScreen); 
    } catch (Exception e) { 
    } 

} 

/*** 
* MyBarcodeDecoderListener 
* <p> 
* This BarcodeDecoverListener implementation tries to open any data encoded 
* in a barcode in the browser. 
* 
* @author PBernhardt 
* 
**/ 
private class MyBarcodeDecoderListener implements BarcodeDecoderListener { 

    public void barcodeDecoded(final String rawText) { 

     //UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen()); 
     UtilityDecoder.saveToHistory(rawText); 

     try { 
      UtilityDecoder.distributeBarcode(rawText); 
     } catch (PIMException e) { 
     } 
    } 

} 

В основном я вызываю scanBarcode(), когда я нажимаю кнопку на панели инструментов.

Может ли кто-нибудь сказать мне, является ли мой код проблемой, или устройством, или чем-то еще? Заранее благодарим за предоставленную помощь!

+0

Сначала увидеть образец демо название «** BarcodeScan Demo **» при условии, начиная с версии 6,0 и далее; Тогда вы можете понять все; – alishaik786

+0

Я следил за демо и читал статью .. как я сказал, это работает 95% времени. Я просто получаю странные сбой –

+0

Где вы получаете сбои? Я запускаю эту демонстрационную демонстрацию, она не получает никаких сбоев, и я создал свою собственную сканирование штрих-кода, взяв предоставленную демонстрацию ;; – alishaik786

ответ

Смежные вопросы