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
hendrik
Posts: 63
Registered: ‎09-10-2009
My Device: Z10, Bold 9700
My Carrier: O2 Germany
Accepted Solution

Open file using InvokeQuery

I successfully implemented a SHARE action, using the following code:

InvokeActionItem* shareItem(InvokeActionItem::create(
    InvokeQuery::create()
        .parent(page)
        .invokeActionId("bb.action.SHARE")
        .mimeType(mimeType)
        .uri(fileURI)));
page->addAction(shareItem, ActionBarPlacement::OnBar);

This works beautifully. For every file that my app downloads and stores in the file system, a SHARE menu item is displayed, which I can use e.g. for emailing the file to someone else.

 

Now I wanted to implement the same for the OPEN action in order to be able to open a file in a different app. This doesn't work at all. Here is my code:

InvokeActionItem* openInItem(InvokeActionItem::create(
    InvokeQuery::create()
	.parent(page)
	.invokeActionId("bb.action.OPEN")
        .mimeType(mimeType)
        .uri(fileURI)));
page->addAction(openInItem, ActionBarPlacement::OnBar);

But I only get this in the log:

Warning: 15:09:54.649 InvocationWrapper::onQueryFinished: no matching result from Menu Service for query
   mimeType="application/pdf"
   uri=QUrl("file:///accounts/ ... /myFile.PDF") 
   data= "" 
   metadata= QMap() 
   perimeter= 0 
   action= "bb.action.OPEN" 
   target= "" 
   invokerIncluded= false 

 

 

I also tried using "data" instead of "uri" and passing in a QByteArray which contains the bytes of the file. This doesn't work either.

 

Curiously, if I leave out both "uri" and "data", it works. An Open In menu item is displayed, which lists apps that can open the specified MIME type. But of course this menu only opens the apps, it doesn't pass the file uri or file data.

 

Is this a limitation of the Dev Alpha devices? Or is there a different way for opening locally stored files in other apps?

----

My Twitter: @hendrik_dev
Developer
oniongarlic
Posts: 83
Registered: ‎10-19-2012
My Device: Playbook, BB10DevAlphaB

Re: Open file using InvokeQuery

Are the files in the shared area ? Otherwise other apps can not access them.
Developer
hendrik
Posts: 63
Registered: ‎09-10-2009
My Device: Z10, Bold 9700
My Carrier: O2 Germany

Re: Open file using InvokeQuery

They are in the data area. But that was not the problem. I now have the confirmation that everything is working as intended on a real Z10 device. So the problem seems to be a limitation of the Dev Alpha OS.

----

My Twitter: @hendrik_dev