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: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi
Accepted Solution

Invoke Share with only C++

I have invoke working from QML but need to call invoke share in a C++ function.

 

Anyone have a simple example?

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Invoke Share with only C++

[ Edited ]

Hi! This post has some sample code:

http://supportforums.blackberry.com/t5/Cascades-Development/sharing-data-from-a-list-item/m-p/222503...

 

First sample shows how to invoke share manually, for example, when user clicked on a button.

 

Second one shows how to create ActionItem which can be added to action bar on Navigation Pane or Sheet.


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Invoke Share with only C++

[ Edited ]

I keep getting back the following error.

Multiple markers at this line
- 'invocation_' was not declared in this
scope
- 'Invocation' has not been declared

Do you think I'm not including a requirement?

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Invoke Share with only C++

After reviewing the code I now think the member variable isn't needed. I'll try to simplify it a bit, please tell if it works:

 

.cpp:

 

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

using namespace bb::cascades;

void CalculatorPage::share_triggered()
{
        QString displayString = "String to share...";

        InvokeQuery *query = InvokeQuery::create()
            .data(displayString.toUtf8())
            .mimeType("text/plain")
            .invokeActionId("bb.action.SHARE");
        Invocation *invocation = Invocation::create(query)
            .parent(this);
                                                                                         
        QObject::connect(invocation, SIGNAL(armed()), this, SLOT(invocation_armed()));
        QObject::connect(invocation, SIGNAL(finished()), invocation, SLOT(deleteLater()));
}

void CalculatorPage::invocation_armed()
{
        qDebug("Invocation armed");
        Invocation *invocation = qobject_cast<Invocation *>(sender());
        invocation->trigger("bb.action.SHARE");
}

In header file:

protected slots:
  void invocation_armed();

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Invoke Share with only C++

Thanks that worked.
_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Invoke Share with only C++

Do you know why it would stop working when I replace.

.mimeType("text/plain")
.data(dataVar)

with
.mimeType("image/png")
.uri(QDir::homePath() + "images/trash.png")
_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Invoke Share with only C++

Unless this is a typo, the slash is missing in path: "/images/..."

 

Try constructing QUrl explicitly:

QUrl url = QUrl::fromLocalFile(QDir::homePath() + "/images/trash.png");

...

.uri(url)

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Invoke Share with only C++

Thanks again Zmey.

I have yet another problem. Take the working code from sharing an image and then change

"bb.action.SHARE"

to

"bb.action.OPEN"

You would think it would work that way but I don't get a response.
_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis