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: 123
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Sharing image via Invocation Framework

QString fileName = QDir::currentPath() + "/camera/A.png";

InvokeRequest invokeRequest;
invokeRequest.setAction("bb.action.SHARE");
invokeRequest.setMimeType("image/png");
invokeRequest.setUri(QUrl::fromLocalFile(fileName));
InvokeTargetReply *tempReply = invokeManager->invoke(invokeRequest);
connect(tempReply, SIGNAL(finished()), this, SLOT(onQueryResponse()));
_queryResults = tempReply;

 

void ApplicationUI::onQueryResponse()
{
	qDebug()<<_queryResults->error(); //Returns 2(Bad request)

	// Clean up the results
	delete _queryResults;
}

 When I try to share an image from my app, I get a Bad request error. What might be wrong? I'm  following the code given in the documentation and reference.

Highlighted
Developer
Posts: 123
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Sharing image via Invocation Framework

Also,  I have set the Access Shared permission. So, it's not a problem with that. What might it be?

Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Re: Sharing image via Invocation Framework

Check the path of the image is right or not
Developer
Posts: 123
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Sharing image via Invocation Framework

I did that.. evrything seems to be in order.. wen I query the targets, I get 12 targets or something.. but some problem happens when I actually send an unbound invocation.
Developer
Posts: 39
Registered: ‎10-13-2010
My Device: LE Z10
My Carrier: Virgin Mobile

Re: Sharing image via Invocation Framework

[ Edited ]

According to the API documentation the fileName should be set to:

 

[php]
QDir::currentPath() + "/shared/camera/A.png";
[/php]


SuhairZain wrote:
QString fileName = QDir::currentPath() + "/camera/A.png";

InvokeRequest invokeRequest;
invokeRequest.setAction("bb.action.SHARE");
invokeRequest.setMimeType("image/png");
invokeRequest.setUri(QUrl::fromLocalFile(fileName));
InvokeTargetReply *tempReply = invokeManager->invoke(invokeRequest);
connect(tempReply, SIGNAL(finished()), this, SLOT(onQueryResponse()));
_queryResults = tempReply;

 

void ApplicationUI::onQueryResponse()
{
	qDebug()<<_queryResults->error(); //Returns 2(Bad request)

	// Clean up the results
	delete _queryResults;
}

 When I try to share an image from my app, I get a Bad request error. What might be wrong? I'm  following the code given in the documentation and reference.




Developer
Posts: 123
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Sharing image via Invocation Framework

The result is same.. also, the uri function takes a QUrl as input..
Developer
Posts: 39
Registered: ‎10-13-2010
My Device: LE Z10
My Carrier: Virgin Mobile

Re: Sharing image via Invocation Framework

Oops. Forgot to prepend the "file://" Have a look at this link.

Developer
Posts: 123
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Sharing image via Invocation Framework

The QUrl::fromLocalFile() returns a url with file:// prepended. That should not be the problem. I manually tried adding it. It doesn't work.