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
slashkyle
Posts: 820
Registered: ‎10-16-2012
My Device: Red Z10
Accepted Solution

Invocation from c++

Since the QML method of share invocations is currently broken (purposely or otherwise) I'm left with c++ 

 

void MyApp::share(QString name, QString surname, QString age)
{
     printf("Share invoked");

     m_pInvocation = Invocation::create(
          InvokeQuery::create()
	       .parent(this)
	       .mimeType("text/plain")
	       .data(name.toUtf8() + surname.toUtf8() + age.toUtf8()));
	  QObject::connect(m_pInvocation, SIGNAL(armed()),
	    this, SLOT(onArmed()));
	  QObject::connect(m_pInvocation, SIGNAL(finished()),
	    m_pInvocation, SLOT(deleteLater()));
}

// Declare the following method as SLOT on your .hpp file
void MyApp::onArmed() {
	m_pInvocation->trigger("bb.action.SHARE");
}

 

found a few samples & this one is most relevant to what i need but it when i try to declare the invocation in my .hpp i get 

'Invocation' does not name a type

private:
    Invocation* m_pInvocation;

 I've included in my .cpp

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

 

 

 

Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Invocation from c++

In .hpp add before class declaration:

namespace bb { namespace cascades { class Invocation; } }

The declaration should look like this:

private:
bb::cascades::Invocation *m_pInvocation;

Andrey Fidrya, @zmeyc on twitter
Developer
slashkyle
Posts: 820
Registered: ‎10-16-2012
My Device: Red Z10

Re: Invocation from c++

Thanks Zmey, its working perfectly now..... still odd that the qml method freezes the app, i'm going to file a issue report on it

Developer
TheMarco
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB

Re: Invocation from c++

Would you mind posting both the cpp and the hpp? I can't figure it out and I need this as well...

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Developer
TheMarco
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB

Re: Invocation from c++

Nevermind! I got it to work as well.

This post was Godsent for me. I spent all night last night trying to get sharing to work with QML. This code did the job. Awesome!!!

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Developer
slashkyle
Posts: 820
Registered: ‎10-16-2012
My Device: Red Z10

Re: Invocation from c++

Glad its working for you too, i've been puzzling over the QML part for over a week & when you mentioned c++ yesterday i figured that was the best we'd get :smileywink:

 

I only found the invocation method in this post & with Zmey's help got it patched together

 

... I did file an issue on the QML side not working as it should 

 

https://www.blackberry.com/jira/browse/BBTEN-874