BlackBerry OS 6.0 中的 QR 码实时扫描

发布于 2024-12-23 13:37:24 字数 1683 浏览 6 评论 0原文

我想在 BlackBerry Os 6 中实现 QR 码阅读器。我在知识库文章的基础上尝试以下代码 如何使用条形码 API

public class ScanScreen extends MainScreen implements BarcodeDecoderListener 
{ 
    private LabelField match; 
    private BarcodeScanner scanner; 
 
    public ScanScreen() 
    { 
        match = new LabelField("Scanning..."); 
        add(match); 
        Vector supported = new Vector(); 
        
        supported.addElement(BarcodeFormat.QR_CODE); 
        
        Hashtable hints = new Hashtable(); 
        
        hints.put(DecodeHintType.POSSIBLE_FORMATS, supported); 
        hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
        
        BarcodeDecoder decoder = new BarcodeDecoder(hints);
        
      try 
        { 
            scanner = new BarcodeScanner(decoder, this); 
            add(scanner.getViewfinder()); 
            scanner.startScan();
        } 
        catch (Exception e) 
        { 
            e.printStackTrace(); 
            match.setText("Exception");
            invalidate();
        } 
    } 
 
    public void barcodeDecoded(String rawText) 
    { 
        match.setText("Found: " + rawText); 
        invalidate();
    } 
 
    public void close() 
    { 
        try 
        { 
            scanner.stopScan(); 
        } 
        catch (Exception e) 
        { 
            e.printStackTrace(); 
        } 
 
        super.close(); 
    } 
} 

该代码不起作用。 它不识别二维码。我尝试关注不同的二维码。但它无法解码 qrcodes。也没有抛出任何异常。请帮助我......

我尝试使用这些设备:BB Pearl 9105 和 BB Storm 9530

I want to Implement a QR Code Reader In BlackBerry Os 6. I try the following Code On the Basis of KB Article How to use the Barcode API.

public class ScanScreen extends MainScreen implements BarcodeDecoderListener 
{ 
    private LabelField match; 
    private BarcodeScanner scanner; 
 
    public ScanScreen() 
    { 
        match = new LabelField("Scanning..."); 
        add(match); 
        Vector supported = new Vector(); 
        
        supported.addElement(BarcodeFormat.QR_CODE); 
        
        Hashtable hints = new Hashtable(); 
        
        hints.put(DecodeHintType.POSSIBLE_FORMATS, supported); 
        hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
        
        BarcodeDecoder decoder = new BarcodeDecoder(hints);
        
      try 
        { 
            scanner = new BarcodeScanner(decoder, this); 
            add(scanner.getViewfinder()); 
            scanner.startScan();
        } 
        catch (Exception e) 
        { 
            e.printStackTrace(); 
            match.setText("Exception");
            invalidate();
        } 
    } 
 
    public void barcodeDecoded(String rawText) 
    { 
        match.setText("Found: " + rawText); 
        invalidate();
    } 
 
    public void close() 
    { 
        try 
        { 
            scanner.stopScan(); 
        } 
        catch (Exception e) 
        { 
            e.printStackTrace(); 
        } 
 
        super.close(); 
    } 
} 

The Code not working. It do not recognize QR codes. I try to focus on different QR codes. But it not decode The qrcodes.Also It not Thrown Any exceptions. Please Help me....

I tried using these Devices: BB pearl 9105 and BB Storm 9530

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼波传意 2024-12-30 13:37:24

我对 BB 开发非常陌生,但我注意到您将“this”作为解码器侦听器参数传递,也许这会导致问题?

    BarcodeDecoder decoder = new BarcodeDecoder(hints);
    BarcodeDecoderListener decoderListener = new BarcodeDecoderListener()
        {
            public void barcodeDecoded(String rawText)
            {
                displayMessage(rawText);
            }
        };

  try 
    { 
        scanner = new BarcodeScanner(decoder, decoderListener)
        add(scanner.getViewfinder()); 
        scanner.startScan();
    } 
    catch (Exception e) 
    { 
        e.printStackTrace(); 
        match.setText("Exception");
        invalidate();
    } 
} 

I'm painfully new to BB development, but I notice you pass "this" as the decoderlistener parameter, perhaps that's causing a problem?

    BarcodeDecoder decoder = new BarcodeDecoder(hints);
    BarcodeDecoderListener decoderListener = new BarcodeDecoderListener()
        {
            public void barcodeDecoded(String rawText)
            {
                displayMessage(rawText);
            }
        };

  try 
    { 
        scanner = new BarcodeScanner(decoder, decoderListener)
        add(scanner.getViewfinder()); 
        scanner.startScan();
    } 
    catch (Exception e) 
    { 
        e.printStackTrace(); 
        match.setText("Exception");
        invalidate();
    } 
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文