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
Gaspertrix
Posts: 35
Registered: ‎09-28-2013
My Device: Dev Alpha B
My Carrier: Movistar

Can not invoke others apps when my app is invoked

I have my app integrated the share menu.

The invocation is working right, I can get the data from invoke request when invoked is fired, but I can not invoke other apps.

 

If I try to open the file picker I get this:

FilePickerPrivate::smileysurprised:nCardInvokeRequestFinished()  . error= 2
"Unable to open File Picker/Saver Card"
InvokeReply::Error= "2"

 

If a try to invoke any other app like the camera I get a "Bad Request" error message.

 

Code:

 

ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
        QObject(app)
{
    .
    .
    .

	connect(invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)), this, SLOT(onInvoke(const bb::system::InvokeRequest&)));

    .
    .
    .
}

void ApplicationUI::onInvoke(const bb::system::InvokeRequest& invoke)
{
	qDebug() << "Action: " << invoke.action();
	qDebug() << "Data&colon; " << invoke.data();
	qDebug() << "mimeType: " << invoke.mimeType();
	qDebug() << "target: " << invoke.target();
	qDebug() << "uri: " << invoke.uri();

	InvokeRequest cardRequest;
	cardRequest.setTarget("sys.camera.card");
	cardRequest.setAction("bb.action.CAPTURE");
	cardRequest.setMimeType("image/jpeg");

	QVariantMap requestData;
	requestData["Data"] = "photo";

	bool ok = true;
	QByteArray encodedRequestData = bb::PpsObject::encode(requestData, &ok);

	cardRequest.setData(encodedRequestData);
	InvokeTargetReply *reply = invokeManager->invoke(cardRequest);

	connect(reply, SIGNAL(finished()), this, SLOT(onInvokeResult()));
	_invokeTargetReply = reply;
}

 

 

 

 

Please use plain text.
BlackBerry Development Advisor
shaque
Posts: 228
Registered: ‎07-14-2008
My Device: Not Specified

Re: Can not invoke others apps when my app is invoked

Try this:

InvokeRequest invokeRequest;
	invokeRequest.setAction("bb.action.CAPTURE");
	invokeRequest.setMimeType("image/jpeg");
	InvokeTargetReply *invokeReply = _invokeManager->invoke(invokeRequest);
Please use plain text.
New Developer
Gaspertrix
Posts: 35
Registered: ‎09-28-2013
My Device: Dev Alpha B
My Carrier: Movistar

Re: Can not invoke others apps when my app is invoked

[ Edited ]

Get bad request error too.

 

The invocation code for camera works fine, If I call it from other part.

The problem is if I call it when my app is invoked. Not only for camera, any other invocation does not work.

Please use plain text.
Developer
ryansweny
Posts: 64
Registered: ‎07-15-2008
My Device: Z10
My Carrier: Rogers

Re: Can not invoke others apps when my app is invoked

I've never gotten this to work etiher.. the same code can invoke when run normally fails when my app has been launched via an invoke. The error message is ErrorBadRequest

 

Sample code that usually works:

void App::launchOtherApp(const QString& url, const QString& targetId, const QString& mime) {
	qDebug() << url << targetId;

    InvokeRequest cardRequest;
    cardRequest.setAction("bb.action.OPEN");
    cardRequest.setMimeType(mime);
    cardRequest.setUri(url);
    cardRequest.setTarget(targetId);

    // Start the invocation
    const InvokeReply *reply = mInvokeManager->invoke(cardRequest);
    if (reply) {
        // Ensure that processInvokeReply() is called when the invocation has finished
        bool ok = connect(reply, SIGNAL(finished()), this, SLOT(processInvokeReply()));
        Q_ASSERT(ok);
        Q_UNUSED(ok);
    } else {
        qDebug() << "Invoke Failed! Reply object is empty.";
    }
}

 

Please use plain text.
Developer
ryansweny
Posts: 64
Registered: ‎07-15-2008
My Device: Z10
My Carrier: Rogers

Re: Can not invoke others apps when my app is invoked

[ Edited ]

Also note that if you are trying to replicate this, if the app is already running via a normal launch then invoking will work the first time, but after the first invoke the app becomes tainted and no further invokes will work.

 

If the app wasn't already running it won't even work once.

 

EDIT: Putting the Invoke in a QTimer with a long delay such as 3 seconds appears to fix it, atleast on 10.2

Please use plain text.
BlackBerry Development Advisor
shaque
Posts: 228
Registered: ‎07-14-2008
My Device: Not Specified

Re: Can not invoke others apps when my app is invoked

I have escalated this issue internally. Can you provide me a small sample app that reproduces the issue? Please include steps to reproduce as well.
Please use plain text.
New Developer
Gaspertrix
Posts: 35
Registered: ‎09-28-2013
My Device: Dev Alpha B
My Carrier: Movistar

Re: Can not invoke others apps when my app is invoked

Sample App:

http://www.forumsmods.com/TestApp.zip

 

It is integrated to share menu, you can share an image and app should open the photo editor with that image shared.

Please use plain text.
BlackBerry Development Advisor
shaque
Posts: 228
Registered: ‎07-14-2008
My Device: Not Specified

Re: Can not invoke others apps when my app is invoked

Thanks! I have logged this internally and escalated it as release gating. 

 

Internal issue ID: NDK-2255

Please use plain text.
New Developer
Gaspertrix
Posts: 35
Registered: ‎09-28-2013
My Device: Dev Alpha B
My Carrier: Movistar

Re: Can not invoke others apps when my app is invoked

Can you confirm me if it is a bug and not an error on how I am doing it?

Please use plain text.
BlackBerry Development Advisor
shaque
Posts: 228
Registered: ‎07-14-2008
My Device: Not Specified

Re: Can not invoke others apps when my app is invoked

Hi,
It is a bug in 10.2 where invoke is getting sent before app is fully foregrounded. A fix is already implemented internally and will get picked up by next external release. For the time being you can either add a delay or listen for foreground event before sending the invoke request.

Shadid
Please use plain text.