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
bmorr
Posts: 318
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus
Accepted Solution

Camera Invoke reply data

I've searched for this and found another thread but I couldn't understand where to put the reply code that was found as the solution.  I also figured if i replied to that thread i would likely not get very much help since it's more than half a year old and was marked as solved.

 

Here's my C++ code:

 

void App::InvokeCamera()
{
	bb::system::InvokeManager manager;
	bb::system::InvokeRequest request;
	request.setTarget("sys.camera.card");
	request.setAction("bb.action.CAPTURE ");
	InvokeTargetReply *targetReply = manager.invoke(request);
}

 I want to retrieve the filepath of the saved image so that I can access it in my app.

 

What and where do I put the reply data?

 

regards,

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

Re: Camera Invoke reply data

You need to connect to the childCardDone signal on your InvokeManager to a slot you create that will handel the results. In the slot, the path of the image will be in the CardDoneMessage.data().

 

Check out https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/card_invoc..., specifically the Listen For a Card Response section.

 

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: Camera Invoke reply data

You also should specify the mime type of the file you want back, as the camera card can do photos or video. Specifying the camera card itself is unnecessary, and leaves the door open for the user using another app that handles the capturing of jpegs.

 

You can do something like this:

	InvokeRequest invokeRequest;
	invokeRequest.setAction("bb.action.CAPTURE");
	invokeRequest.setMimeType("image/jpeg");
	InvokeTargetReply *invokeReply = _invokeManager->invoke(invokeRequest);

 

 

https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/camera.htm...

 

Also, consider the FilePicker API, which will let your user either select an exsiting image, or capture a new one with the camera. You don't have to care where the image came from if it doesn't matter to you or your app.

 

https://developer.blackberry.com/native/documentation/cascades/ui/pickers/filepicker.html

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
bmorr
Posts: 318
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus

Re: Camera Invoke reply data

So this just goes underneath directly following the original code?

Please use plain text.
Developer
bmorr
Posts: 318
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus

Re: Camera Invoke reply data

bump  at this point i'm really just confused about WHERE to put the reply code.

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

Re: Camera Invoke reply data

It's its own method. This is using Qt's Signals and Slots functionality. You can read about that here:

https://developer.blackberry.com/native/documentation/cascades/dev/signals_slots/index.html

 

It's pretty fundamental to developing in Cascades, so I would highly recommend you develop a solid understanding of it.

 

For a working example, you could try https://github.com/blackberry/Cascades-Samples/blob/master/invokeclient/src/app.cpp and https://github.com/blackberry/Cascades-Samples/tree/master/invoketarget

 

 

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
bmorr
Posts: 318
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus

Re: Camera Invoke reply data

Thanks Paul.  I'm just starting out and while I understand in general what the slots and signals do, I just have to get more comfortabe with knowing how to use them in the code.  I'll check out the documentation in that link.  I appreciate it.

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

Re: Camera Invoke reply data

No problem! Let us know if you have any other questions, we are happy to help :smileyhappy:

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
bmorr
Posts: 318
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus

Re: Camera Invoke reply data

I've put the connections in the App UI like so:

 

	    connect(invokeManager,
	    SIGNAL(childCardDone(const bb::system::CardDoneMessage&)), this,
	    SLOT(childCardDone(const bb::system::CardDoneMessage&)));

 and I've created the functions for the invoked camera and the childcardDone like so:

 

void App::InvokeCamera()
{
	bb::system::InvokeManager manager;
	bb::system::InvokeRequest request;
	request.setTarget("sys.camera.card");
	request.setAction("bb.action.CAPTURE ");
	request.setMimeType("image/jpeg");
	InvokeTargetReply *targetReply = manager.invoke(request);

}

void App::childCardDone(const bb::system::CardDoneMessage &message)
{
	 message.data();
}

 How do I connect to the message.data?

Please use plain text.
Developer
bmorr
Posts: 318
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus

Re: Camera Invoke reply data

I know it's working because when i looka t the terminal the debug shows this:

 

"save" 
 
"image/jpg" 
 
"/accounts/1000/shared/camera/IMG_00000069.jpg" 

 Now I don't know how I'd make this info show up in the QML:

 

Container {
                                    topPadding: 20
                                    Label {
                                        id: imagePath
                                        text: qsTr("Image Filepath: ") + Retranslate.onLanguageChanged
                                    }
                                }


Container {
                                        
                                        
                                        Button {
                                            preferredWidth: 300
                                            imageSource: "asset:///images/ic_camera.png"
                                            onClicked: {
                                                _app.InvokeCamera()
                                                _app.childCardDone()
                                            }
                                        } 
                                    }

 I want the image filepath to show up in the "Image Filepath" Label.  I've never gotten information from the C++ code before I've only ever triggerred functions.

Please use plain text.