Java Zxing qr扫描黑莓崩溃

Java Zxing qr扫描黑莓崩溃,java,blackberry,crash,qr-code,zxing,Java,Blackberry,Crash,Qr Code,Zxing,我正在为黑莓设备实现二维码扫描仪,我正在使用ZXing库来实现这一点。顺便说一下,这是针对OS6+的。我遇到的问题是,有时候,只是有时候,当相机打开准备扫描时,设备会冻结并完全重新启动 除此之外,它大部分时间都能工作,我可以扫描和解码二维码等。然而,它似乎偶尔会无缘无故地崩溃。我不知道是相机的问题还是我的代码中的问题,但我会提供代码 public void scanBarcode() { // First we create a hashtable to hold all of the

我正在为黑莓设备实现二维码扫描仪,我正在使用ZXing库来实现这一点。顺便说一下,这是针对OS6+的。我遇到的问题是,有时候,只是有时候,当相机打开准备扫描时,设备会冻结并完全重新启动

除此之外,它大部分时间都能工作,我可以扫描和解码二维码等。然而,它似乎偶尔会无缘无故地崩溃。我不知道是相机的问题还是我的代码中的问题,但我会提供代码

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

}
public void scanBarcode(){
//首先,我们创建一个哈希表来保存所有我们可以保存的提示
//提供有关如何扫描条形码以提高速度的API
//和准确性。
Hashtable hints=新的Hashtable();
//首先是一个格式列表。我们可以查找
//一次不止一个,但速度要慢得多。
向量格式=新向量();
格式.附录(条形码格式.QR_码);
提示.put(DecodeHintType.mables_格式,格式);
//我们还将使用“更加努力”的标志,以确保我们获得
//精确扫描
put(DecodeHintType.TRY_,Boolean.TRUE);
//我们使用这些提示创建了一个新的解码器
条形码解码器=新条形码解码器(提示);
//最后,我们可以创建带有解码器和
//将处理条形码中存储的数据的侦听器
//在我们的视图屏幕中处理显示。
试一试{
_扫描仪=新条码扫描仪(解码器,新MyBarcodeDecoderListener());
_条形码屏幕=新的MyBarcodeScannerViewScreen(_扫描器);
}捕获(例外e){
返回;
}
//如果我们到了这里,所有的条形码扫描基础设施都应该设置好
//我们要做的就是开始扫描并显示取景器
试一试{
_scanner.stopScan();
_scanner.getPlayer().start();
_scanner.startScan();
UiApplication.getUiApplication().pushScreen(_条形码屏幕);
}捕获(例外e){
}
}
/***
*MyBarcodeDecoderListener
*
*此BarcodeDecoverListener实现尝试打开任何已编码的数据
*在浏览器中的条形码中。
* 
*@PBernhardt作者
* 
**/
私有类MyBarcodeDecoderListener实现BarcodeDecoderListener{
已解码公共无效条形码(最终字符串rawText){
//UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
实用解码器。保存历史记录(rawText);
试一试{
实用解码器。分配密码(rawText);
}捕获(PIME例外){
}
}
}
当我单击工具栏上的按钮时,我基本上调用scanBarcode()

有谁能告诉我是我的代码出了问题,还是设备出了问题,还是其他什么问题?提前感谢您提供的任何帮助

试试这个链接:

查看此forun链接并查看该链接的讨论。当然,您将获得条形码扫描的总体概念,并在5.0版中实现QRCode

尝试以下链接:

查看此forun链接并查看该链接的讨论。当然,您将获得条形码扫描的总体概念,并在5.0版中实现QRCode


首先看到的示例演示名称是6.0版之后提供的“条形码扫描演示”;这样你就可以理解一切;我已经跟随演示并阅读了这篇文章。。正如我所说的,它95%的时间都能工作。。我只是有点奇怪的撞车你在哪里撞车?我运行这个示例演示,它没有出现任何崩溃,我通过使用提供的演示创建了自己的条形码扫描演示;;那么我猜一定是我的黑莓设备导致了这个问题。首先看到示例演示名是“BarcodeScan demo”,它是从6.0版开始提供的;这样你就可以理解一切;我已经跟随演示并阅读了这篇文章。。正如我所说的,它95%的时间都能工作。。我只是有点奇怪的撞车你在哪里撞车?我运行这个示例演示,它没有出现任何崩溃,我通过使用提供的演示创建了自己的条形码扫描演示;;那么我想一定是我的黑莓手机造成了这个问题。