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
Highlighted
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi
Accepted Solution

Invoke Camera QML

Have the following 

 

        Invocation {

            id: cameraInvocation            

            query {

                invokeTargetId: "sys.camera.card"

                mimeType: "image/jpeg"

                invokeActionId: "bb.action.CAPTURE"

                data: "photo"

            }

        }

 

 

and I'm attempting to call it with

 

cameraInvocation.trigger("bb.action.CAPTURE");

 

 

But I get back an error when trying to run the invoke.

 

InvocationWrapper:Smiley SurprisednQueryFinished: no matching result from Menu Service for query

   mimeType="image/jpeg"

   uri=QUrl("") 

   data= "photo" 

   metadata= QMap() 

   perimeter= 0 

   action= "bb.action.CAPTURE" 

   target= "sys.camera.card" 

   invokerIncluded= false 

InvocationPrivate:Smiley SurprisednQueryResolved: no result matching query, no armed signal sent. 

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Retired
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Invoke Camera QML

Hi

 

unfortunately you've hit a known issue for which a fix is on the way. In the meantime you should use the InvokeManager API from C++.

 

Regards

 

Martin

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Invoke Camera QML

I believe you can also work around it by not specifying the target ID (do you really care if the user gets the image from the offical camera app? It's not present in the work perimiter, for example, so if you ever want your app deployed there your invocation will need to be more generic)

 

You can also use file picker and specify that you want an image. The user can then select the camera from there, or pick a photo they have already captured.

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: 237
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: Invoke Camera QML

Why not just include your own camera functionality instead of invoking the camera app? try https://github.com/blackberry/Cascades-Samples/tree/master/photobomber

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

Re: Invoke Camera QML

Depends on your use case. The main reason you wouldn't want to just add your own camera control is because then you have to build a bunch of UI to control it. The camera card will do things like focus regions and modes, HDR, different aspect ratios, scene modes, and a whole host of other stuff that you would have to either replicate or accept as lost functionality.

 

Why do that when you can simply invoke it or use the file manager for less work? Smiley Happy

 

The camera control is really only for if you are going to do something special with the camera, like apply filters or do panoramas or scan barcodes or whatnot.

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: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Invoke Camera QML

1. I think it's better to use the card then roll my own both in terms of end result and amount of work.

2. I've used the filepicker before and yes it's very easy, however I'm building a game in which using a photo downloaded from google would be an easy way to cheat(a photo scavenger hunt) so I only want the user to be able to use the camera.

 

Since posting I've moved to using C++ for this with the following function 

 

voidApplicationUI::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);

}

 

 

The difficulty now is getting the photo taken in the card back into my app so I can use it. Not sure of the best way to do that I think I'll have to use a signal and a slot. It was so much easier when I was using the file picker.

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Invoke Camera QML

Yes, that is an excellent reason for using the card, and the built in one specifically.


Getting the photo back isn't that hard, You do need to use a signal/slot though. They are great!

 

You just need to connect to the InvokeManager's childCardDone signal. If you get "save" back as the reason, then the data attribute will hold the path to the captured image. From there, you can do what you want with it (if your app needs it for more than a few seconds, you should proably copy it into the data folder of your app so the user can't delete or swap it. Make sure there is some process to delete that later, as the user can't manually do anything to your data folder short of uninstalling the app)

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