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
Regular Contributor
ametller
Posts: 54
Registered: ‎07-15-2010
My Device: Not Specified
Accepted Solution

Invokation framework. Problem sharing simple text

Hello,

 

I would like to have an option to share simple text on my application. For this I'm using this code in my .QML file:

 

ActionItem {
     attachedObjects: [
          Invocation {
               id: invoke
               query: InvokeQuery {
                    id: invokeQuery
                    mimeType: "text/plain"
                    data: "This is a text text"
               }
          }
     ]
     
     title: qsTr("Share")
     imageSource: "asset:///images/share.png"
     ActionBar.placement: ActionBarPlacement.OnBar
     onTriggered: {
          invoke.trigger("bb.action.SHARE")
     }
}

 With the text above I can see the hardcoded text appear in all the applications I can share it to (the bold line), however, if I use the following line to change the text dynamically for the current element of the List instead I get nothing. No text is shared at all:

 

data: ListItemData.description

 Did anybody was able to successfully share a plain dynamic text?

 

Thanks,

Please use plain text.
Regular Contributor
ametller
Posts: 54
Registered: ‎07-15-2010
My Device: Not Specified

Re: Invokation framework. Problem sharing simple text

Well, I managed to get a solution, but I had to use C++ instead of QML. Here you have it, just in case any of you have the same problem:

 

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");
}
Please use plain text.