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
oddboy
Posts: 136
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

Re: using bb.action.SHARE - odd behaviour

thanks a ton for your help slashkyle.

 

I just can't seem to get it to work.

 

error is: 

 

   -> App: appHelper::share(): fileName -  "file:///accounts/1000/appdata/<blah blah>/shared/camera/IMG_00000468.jpg" 
InvocationWrapper::onInvokeFinished: invocation failed with error 2 
Invocation failed for action="bb.action.SHARE", target="sys.invokeTargetSelection", reason="BadRequest"
InvocationWrapper::onInvokeFinished: action = "bb.action.SHARE" , target = "sys.invokeTargetSelection" 

 

...for reference: 

 

void appHelper::share(QString fileName) {

		fileName = fileName.prepend("file://");
		qDebug() << "   -> App: appHelper::share(): fileName - " << fileName ;
		InvokeQuery *query = InvokeQuery::create()
			.uri(fileName); //.mimeType("image/jpg").data(fileName.toUtf8());


		Invocation *invocation = Invocation::create(query);
		query->setParent(invocation); // destroy query with invocation
		invocation->setParent(this); // app can be destroyed before onFinished() is called
		connect(invocation, SIGNAL(armed()), this, SLOT(onArmed()));
		connect(invocation, SIGNAL(finished()), this, SLOT(onFinished()));
}
void appHelper::onArmed() {
	 Invocation *invocation = qobject_cast<Invocation *>(sender());
	 invocation->trigger("bb.action.SHARE");
}
void appHelper::onFinished() {
	Invocation *invocation = qobject_cast<Invocation *>(sender());
	invocation->deleteLater();
}

 maybe i just need to sleep on it.

 

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Please use plain text.
Developer
slashkyle
Posts: 820
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: using bb.action.SHARE - odd behaviour

for this function you wont need a uri or .data,

 

make sure you have these includes in your .cpp

#include <bb/cascades/InvokeQuery>
#include <bb/cascades/Invocation>

 

.hpp

namespace bb
{
    namespace cascades
    {
        class Application;
        class Invocation;
    }
}

 forgot about them when I posted the working code, one reason I perfer qml to c++ in qml things don't have to be declared multiple times in different places (i refer to that as the ++ :smileywink: )

 

 

Please use plain text.
Developer
oddboy
Posts: 136
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

Re: using bb.action.SHARE - odd behaviour

well, i'm going to go with Solved.

 

still doesn't work on my device (10.2.0.1371), but works fine on my wife's (10.1.0.273).

 

Thanks again slashkyle!

 

 

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Please use plain text.