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

Posts: 196
Registered: ‎12-14-2009
My Device: Not Specified
Accepted Solution

Invoke Share on Multiple Files?

I have my multiple selection up and running and can get the QVarient QList from the 

selectionList() successfully.


I'm stuck at trying to get to share these all in one share. 


     Invocation {
                    id: sharefilesinvoke
                    property bool auto_trigger: false
                    query {
                        mimeType: "filelist/mixed"
                        uri: "list:///"
                    onArmed: {
                        if (auto_trigger) trigger("bb.action.SHARE");
                        auto_trigger = true;

 Then I was trying


sharefilesinvoke.query.data = listViewid.selectionList();


 to see if it would be easy but nope.


Also tries with uri: "file:///" in the invocation to no avail.


Then I look here:


and maybe here:



just to research and it looks like json data is needed. I tried a test though:


sharefilesinvoke.query.data = "[{\"uri\":\"file://"+listViewid.selectionList()[0].url+"\"" +"}]"


 but that didn't work either. Any thoughts?



Posts: 426
Registered: ‎04-10-2011
My Device: Z30

Re: Invoke Share on Multiple Files?

Did you also try setting the sharefilesinvoke.query.data as a JavaScript object instead of stringified to JSON?
Check out my apps in the BlackBerry World
Visit my developer blog alopix.net
BBM Channel: C0047B612
Posts: 196
Registered: ‎12-14-2009
My Device: Not Specified

Re: Invoke Share on Multiple Files?

[ Edited ]

It's working!


I tried that and I also was forgetting to 



 not sure which did it but it is working. Now I just have to make a javascript loop over the entire list items and insert them into a JSON format.

Posts: 65
Registered: ‎03-20-2013
My Device: Z10(Red Limited Edition)
My Carrier: MY COMPANY

Re: Invoke Share on Multiple Files?

Hey,Can you elaborate in details


Posts: 587
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Re: Invoke Share on Multiple Files?

For reference, here is what I did and it seems to be working:


            foreach(QVariant indexItem, selectionList)
                QVariantList indexPath = indexItem.toList();
                QVariantMap item = m_photoGridModel->data(indexPath).toMap();

                QString fileName = item["image"].toString();

                QVariantMap fileItem;
                fileItem["uri"] = QString("file://") + fileName;


            JsonDataAccess jda;
            QString jsonBuffer;
            jda.saveToBuffer(files, &jsonBuffer);

            invocation = Invocation::create(
            invokeActionId = "bb.action.SHARE";
            connect(invocation, SIGNAL(armed()), this, SLOT(onInvocationArmed()));
            connect(invocation, SIGNAL(finished()), invocation, SLOT(deleteLater()));

 ... where "selectionList" is a QVariantList of things I want to send, and the "image" key of those QVariantMaps is the file name.


Proably of most interest is how I'm creating some "JSON", which is actually just a QVariantList of QVariantMap, where each QVariantMap has its "uri" set.  You can then use JsonDataAccess to render that as a string, and set the .data of the InvokeQuery, etc.