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: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany
Accepted Solution

Share a textfile

I would like to share a text file with all the possible targets, but the invocation automatically opens an email with the file attached.

I can click the attachment and select share, but i'd like to get this selection by default.

What is wrong?

 

InvokeRequest shareRequest;
shareRequest.setAction("bb.action.SHARE");
shareRequest.setMimeType("text/plain");
shareRequest.setUri("file:///" + filePath);
invokeManager->invoke(shareRequest);

 

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Share a textfile

[ Edited ]

Is it possible that's the only app registered for text/plain? If that's the case then you wouldn't see a menu with other choices.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Share a textfile

But how does the text viewer application do it?
when i click the attached file in the email it opens the text viewer, and if i click "share" in there i get the full list.

if i omit the mimetype it still opens the email.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Share a textfile

To answer my own question:

Instead of an InvokeRequest you have to use an InvokeQuery.

 

void DataServiceUtil::shareFile(QString filePath) {
  invocation = Invocation::create(InvokeQuery::create().parent(this).uri("file:///" + filePath));
  invokeActionId = "bb.action.SHARE";
  connect(invocation, SIGNAL(armed()), this, SLOT(onArmed()));
  connect(invocation, SIGNAL(finished()), invocation, SLOT(deleteLater()));
}

 onArmed just calls trigger on the invocation

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter