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

Native Development

Reply
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Barcode scanner not working for second time after closing the camera

Hi,

 

I have a requirement to scan the BARCODE or QRCODE from my app. My code is as below.

I need to call my function after scanning the code. I have to close the camera upon scanning. So, I use camera.close() .

Now the user can again scan a code so i need to open the camera using camera.open()

but, this time the camera is not scanning the code.

 

My code is as below (in QML)

 

 

            Container {
                layout: DockLayout {}
                Camera {
                    id: camera
                    visible: false;
                    horizontalAlignment: HorizontalAlignment.Fill
                    verticalAlignment: VerticalAlignment.Fill
                    onCameraOpened: {
                        getSettings(cameraSettings)
                        cameraSettings.focusMode = CameraFocusMode.ContinuousAuto
                        cameraSettings.shootingMode = CameraShootingMode.Stabilization
                        applySettings(cameraSettings)
                        camera.startViewfinder()
                    }
                    attachedObjects: [
                        BarcodeDetector {
                            id: barcodeDetector
                            camera: camera
                            formats: BarcodeFormat.Any
                            onDetected: {
                                camera.setVisible(false);
                                camera.close();
                                app.barcodeScannedResult (data);
                                scannedSound.play();
                            }
                        },
                        SystemSound {
                            id: scannedSound
                            sound: SystemSound.GeneralNotification
                        },
                        CameraSettings {
                            id: cameraSettings
                        }
                    ]
                }
            }

 

Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Barcode scanner not working for second time after closing the camera

I believe it should be working.. If you connect to the scanStarted signal do you get anything? Any errors in the logs?

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
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: Barcode scanner not working for second time after closing the camera

Hi,

There isn't any error. camera opens second time but unable to detect any code.
even for simple barcode .

Regards,
Sanjeev
Retired
Posts: 252
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: Barcode scanner not working for second time after closing the camera

Hi sanj1504,

 

Have you looked up the barcodereader sample app: https://github.com/blackberry/Cascades-Samples/tree/master/barcodereader? It works and correctly scans and reads barcodes as expected.

 

If you think you are facing a bug, please isse a defect log on jira: https://www.blackberry.com/jira/secure/Dashboard.jspa 

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: Barcode scanner not working for second time after closing the camera

Hi,

 

I need to open camera for barcode reading on click of a button. so i have handled that case using 

 

camera.open();
// camera is the id for camera object in qml

 

once it gets the bar code's actual value or decodes it, camera has to stop and i use 

 

camera.close();
// once barcodeDetected signal is emitted

 now again the user wants to scan the code, this time only the camera opens but unable to detect any code. 

 

this is my issue.

Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Barcode scanner not working for second time after closing the camera

You could try re-setting the BarcodeDetector's Camera property to be the camera once you re-open the camera. You could also create one dynamically, though obviously we'd defintely like to get this working too.

 

Can you copy and paste some of the logs you are getting? I wonder if it's not adding the preview buffers correctly the second time you run it.

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
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: Barcode scanner not working for second time after closing the camera

Yes, Next time it is not adding preview buffer. Camera is just open an no logs are except for camera open.
Highlighted
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Barcode scanner not working for second time after closing the camera

What OS are you testing this on?

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
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: Barcode scanner not working for second time after closing the camera

on the phone it is 10.1.0.4181
IDE SDK is 10.1.0.4828
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: Barcode scanner not working for second time after closing the camera

How to add preview buffer from QML.