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
New Developer
yoan
Posts: 13
Registered: ‎12-17-2012
My Device: Simulator
My Carrier: Telenor

Create/Open Camera on button click (not opened from start)

Hi,

 

Trying to find a sample where the camera is opened from a button click. All examples i can find the camera view is already opened from start. 

 

Any help to point me in the right direction would be much apprisiated!

 

/Johan

Please use plain text.
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)
My Carrier: Mobile Vikings

Re: Create/Open Camera on button click (not opened from start)

Do you want to integrate a custom camera view in your app or do you want to invoke the camera?

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
New Developer
yoan
Posts: 13
Registered: ‎12-17-2012
My Device: Simulator
My Carrier: Telenor

Re: Create/Open Camera on button click (not opened from start)

I just want to invoke the camera, get the image taken, upload it to my server. 

Please use plain text.
Developer
billbsb
Posts: 144
Registered: ‎03-25-2011
My Device: Playbook, Z10 L.E.
My Carrier: Vodafone NL

Re: Create/Open Camera on button click (not opened from start)

Hi there! Any luck with it? I'm trying to implement the same thing.

 

Have you seen this other thread? http://supportforums.blackberry.com/t5/Cascades-Development/Invoke-camera-card-in-qml/m-p/2319141/hi...

 

Cheers!

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

Re: Create/Open Camera on button click (not opened from start)

Do you want to invoke the camera card, or build the camera UI inside your application? Invoking the camera card will require a bit of C++ (as mentioned in that thread), but can definitely be done. Starting and stopping the camera viewfinder from inside your app is also pretty easy, and can be done in QML. I believe the BarcodeScanner app starts the viewfinder after you press on the screen.

 

https://github.com/blackberry/Cascades-Samples/tree/master/barcodereader

 

You can just call camera,open(CameraUnit.Rear) at any point in your app, really.

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.
Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Create/Open Camera on button click (not opened from start)

Actually, why do you want to delay opening the camera? Even if you don't want it to be the first thing you see in the app, you probably want to have it off on it's own page.

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.
Developer
billbsb
Posts: 144
Registered: ‎03-25-2011
My Device: Playbook, Z10 L.E.
My Carrier: Vodafone NL

Re: Create/Open Camera on button click (not opened from start)

On the docs page states that you can invoke the Camera app but it never mentions you can invoke it via QML so maybe this could be clearer.

 

But then I saw on this other docs page that you can already invoke some Cards in QML using the InvokeActionItem but apparently it doesn't work for the Camera app. So this is actually the new feature that I need. The work around is to do everything in C++ so It's not really high priority.

 

While reading all those pages I realized something: I want to integrate the device's cameras on my application without having to implement a complex camera module. I'm not an expert on camera stuff like focus, exposure, face detection and so on. But I know there's a high change that the user has other dedicated, feature rich Camera apps installed on their device so I want to be abble to leverage them.

 

But I guess this is not possible now, right? I was expecting to find something like bb.action.CAPTURE so I could invoke any app that can take pictures. Should this be another feature request?

 

I hope this is clear.

Cheers.

 

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

Re: Create/Open Camera on button click (not opened from start)

InvokeActionItem is a specialized class for automatically handling invocation of a certain subset of targets. It's really nice because it will do things like give you the correct icon, and handle the GUI to select the target you want to share to. It doesn't support any sort of generic invocation right now, unfortunately.

 

For things like the camera card specifically, you will notice that there is no onChildCardDone funciton or similar, so there is no way to get data back from an InvokeActionItem to begin with. This is definitely FR territory, so if you want to see it, please log it on the DIT.

 

If you want to invoke other apps registering for the bb.action.CAPTURE action, right now you would have to build the GUI yourself, but it would be possible. Might be a good FR to have that done in a generic way as well.

 

You probably don't want to build a camera UI yourself if you aren't doing something specific with that UI (ie, applying filters to the viewfinder, or drawing something over top of it). Depending on your use case, the camera card might not be the best option either. If you just want a jpeg that may or may not have been captured right now, you can use the FilePicker class. If you ask for a image, it will default to the camera folder, and have a button for the user to capture a picture right then and there. You can also do all of that right in QML.

 

I'd generally recommend the FIlePicker over the card, but it's worth considering either way.

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.
Contributor
ThierryGrellier
Posts: 23
Registered: ‎01-08-2013
My Device: dev alpha
My Carrier: elisa

Re: Create/Open Camera on button click (not opened from start)

sorry to hijack the thread but this somehow is related to the question, and my cluster interest...

I too would have wished not resorting on C++ to invocate the camera. In the first version, I've basically embeded the came a la bomber example, but I would still like to have the full settings in the camera for the end user, and don't want to reinvent the wheel (that's what cards are for).
So, it's one more step for the user to go to the camera from file picker, which could I could have live with, but I need the front camera, which I don't have by default  throught the file picker. I'd welcome the addition of a parameter to the filepicker card to tell which camera to use by default, that basically is having a complimentary sub query for the camera .

The other issue I have in the simulator that now "supports" the camera, is that it doesn't support the picture editor, that is it will raise a target not found error when setting  imageCropEnabled: true.  So I'd like to know if there is a way detecting that we are running in the simulator to have something like imageCropEnabled: not_in_simulator. I see that the model is BBSIM in the hardware settings, but I've got RIM BlackBerry Device in HardwareInfo.deviceName... I can check on the later to assume it is the simulator. But not sure how stable the name is.

I would have loved adding these request to jira, but the page nicely live locks when loading for me.

Please use plain text.