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: 403
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: Problems with the barcode reader sample

[ Edited ]
Developer
Posts: 403
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: Problems with the barcode reader sample

Here is my source example.

 

import bb.cascades 1.0
import bb.cascades.multimedia 1.0
import bb.multimedia 1.0

Page {
    Container {
        Camera {
            id: camera
            preferredWidth: 768.0
            preferredHeight: 768.0
            onCameraOpened: {
                // Apply some settings after the camera was opened successfully
                getSettings(cameraSettings)
                cameraSettings.focusMode = CameraFocusMode.ContinuousAuto
                cameraSettings.shootingMode = CameraShootingMode.Stabilization
                applySettings(cameraSettings)

                // Start the view finder as it is needed by the barcode detector
                camera.startViewfinder()
            }
            onViewfinderStarted: {
                // Setup the barcode detector with the camera object now
                barcodeDetector.camera = camera
            }
            onViewfinderStartFailed: {
                resultLabel.text = error;
            }
            attachedObjects: [
                CameraSettings {
                    id: cameraSettings
                }
            ]
        }
        Container {
            id: resultArea
            horizontalAlignment: HorizontalAlignment.Fill
            Label {
                text: "QRCode Results"
            }
            Label {
                id: resultLabel
                multiline: true
            }
            Button {
                onClicked: {
                    camera.open();
                }
                text: "second camera.open()"
            }
        }
    }
    onCreationCompleted: {
        // Check to see if any cameras are currently accessible.
        if (camera.allCamerasAccessible) {
            // Open the rear camera.
            camera.open();
        }
    }
    attachedObjects: [
        BarcodeDetector {
            id: barcodeDetector
            formats: BarcodeFormat.Any
            onBarcodeDetected: {
                if (resultLabel.text != data) {
                    resultLabel.text = data;
                    resultArea.visible = true;
                    scannedSound.play()
                }
            }
        },
        SystemSound {
            id: scannedSound
            sound: SystemSound.GeneralNotification
        }
    ]
}

 

Only when the button is pressed will it scan the QRCode.

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

Re: Problems with the barcode reader sample

Thanks Bluenoser. I'm tracking down the bug internally, and I'll update the DIT issue when I've found 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: 403
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: Problems with the barcode reader sample

Paul,

 

  Is there any progress? Being able to scan barcodes/QR codes is more or less a necessity for any mobile app. I have a cascades apps that I am working on an QR Codes are required and the example app is cludgy and testers don't like it.

Retired
Posts: 47
Registered: ‎04-19-2013
My Device: I love them all!
My Carrier: Carriers rock!

Re: Problems with the barcode reader sample

Camera {
    attachedObjects: BarcodeDetector {
        camera: camera
        formats: BarcodeFormat.Any
        onDetected: {
           // Content of the barcode is delivered as 'data'
        }
    }
                   
    id: camera

    onCameraOpened: {
        camera.startViewfinder();
    }
}

Button {
    id: buttonCamera
    text: "Start Detector"

    onClicked: {
        camera.open();
    }
}

 That is the simplest barcode scanner I could come up with.  It would be left to the developer to do something with the data, like calling camera.close() after you have received the data from a scanned barcode.

Developer
Posts: 403
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: Problems with the barcode reader sample

Hi,

 

  Did you try your app and was it able to scan QR Codes without any issues?

Retired
Posts: 47
Registered: ‎04-19-2013
My Device: I love them all!
My Carrier: Carriers rock!

Re: Problems with the barcode reader sample

I didn't experience any issues scanning barcodes, but perhaps I'm not looking for your specific issue?  Can you describe exactly what problems you're having?

New Contributor
Posts: 4
Registered: ‎04-12-2013
My Device: none
My Carrier: ZTE

Re: Problems with the barcode reader sample

It is very simply to integrate barcode scanning component in your application with this free user-defined barcode reader implementation tutorial.

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Problems with the barcode reader sample


abbyyy wrote:

It is very simply to integrate barcode scanning component in your application with this free user-defined barcode reader implementation tutorial.


dotNet will not be very helpful on BB10

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
Developer
Posts: 403
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: Problems with the barcode reader sample

For me, this problem has been fixed by the updates to the SDK.