Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
Accepted Solution

QR Code scanning camera pop issue

Hi, I am trying to scan QR code with my code. My code is running fine with 5.0(Bold) and 7.1(Torch) OS phones. It is running fine with 7.1 and 5.0. but giving problem while running with 6.0 OS(Bold 9700). The problem is - "While trying to scan QR code, app scans the QR code but camera screen doesn't pop and it remains at the front. Event it is not able to hide by using Esc key". please help me to resolve the issue with os6. Ankit
Please use plain text.
Developer
Dionysus
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900

Re: QR Code scanning camera pop issue

Could you post a code snippet for us to try and assist you.

Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800

Re: QR Code scanning camera pop issue

I am using following code to pop the camera screen:

 

'UiApplication.getUiApplication().invokeLater(new Runnable() {

public void run() {

UiApplication.getUiApplication().popScreen(_QRcodeScreen);

}

});

 

I tis running but, still camera doesn't pop and further actions works behind the camera screen.

Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800

Re: QR Code scanning camera pop issue

[ Edited ]

Edit:

Code while opening camera screen for QR code scan:

 

 

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 QR code. We put

// that in our view screen to handle the display.

try {

        _scanner = new BarcodeScanner(decoder, new LeadQRcodeDecoderListener());            

        _QRcodeScreen = new LeadQRcodeScannerViewScreen(_scanner);

 

       // If we get here, all the QR code scanning infrastructure should be set

       // up, so all we have to do is start the scan and display the viewfinder

       _scanner.startScan();

       UiApplication.getUiApplication().pushScreen(_QRcodeScreen);

}

catch (Exception e) {

       e.printStackTrace();

       return;

}

 

And code for closing screen is:

 

UiApplication.getUiApplication().invokeLater(new Runnable(){
   
public void run(){
       
UiApplication.getUiApplication().popScreen(_QRcodeScreen);
   
}
});

 

 

-------------------------------------------------------------------------------------------------------------------------

 

I am using the above metioned code.

Please use plain text.
Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

Re: QR Code scanning camera pop issue

Are you calling _scanner.stopScan() anywhere? I would make sure you're doing that if you aren't already.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800

Re: QR Code scanning camera pop issue

Hi All,

 

I have solved my issue for os 6. After scanning of QR code, closing all player and scanner connection.

Have used-

 

if (_scanner != null && _scanner.getPlayer() != null) {
_scanner.getPlayer().close();
}

 

It is helpful to me.

Please use plain text.
Developer
avinash_kumar_ispg_in
Posts: 172
Registered: ‎01-02-2012
My Device: 8520 curve

Re: QR Code scanning camera pop issue

Hi i am also doing with the QR code scanning it is running fine

 

But my problem is that i want to add one button on camera screen while it is opening to scan the QR code, to handel some action like to navigate on other screen or to close the current screen itself etc...

 

 can you help me

 

thanks

Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800

Re: QR Code scanning camera pop issue

Hi avinash,

                    You can add menu list instead of adding button. Because adding any field on viewport(camera) is available from Os 7.1. So you can use the following way:

 

 

Use code in class to add menu list:

 

protected void makeMenu(Menu menu, int instance) {
    super.makeMenu(menu, instance);
    menu.deleteAll();

    menu.add(new MenuItem("Close", Const.MENU_ORDINAL, Const.MENU_PRIORITY)
    {
        public void run() {
            // Action

        }
    });
}

 

You can also add more items to menu list by using menu.add(.....)

It is helpful to me.

 

Prease press like, if you are satisfied with this answer.

Please use plain text.