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: 102
Registered: ‎06-03-2012
My Device: Playbook
My Carrier: *

Sharing a PNG image file only shows "BBM Group"

Hi guys,

 

I'm trying to share a PNG image file from C++. The problem is, I'm only getting the option to share via "BBM Group". I was hoping to get "BBM", "NFC", etc. as well.

 

Using QML code I get the desired result, but using C++ not. And I need to use C++ for that.

 

    QString path = QDir::current().absoluteFilePath("data/wallpaper.png");

    bb::system::InvokeRequest request;
    request.setMimeType("image/png");
    request.setAction("bb.action.SHARE");
    request.setUri(QUrl::fromLocalFile(path));
    bb::system::InvokeTargetReply *reply = m_invokeManager.invoke(request);

 

-----------
http://kodira.de
BB Apps: Pattern :: Plonk
BlackBerry Development Advisor
Posts: 15,084
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Sharing a PNG image file only shows "BBM Group"

The code you have triggers an unbound invocation, which means it'll just open using the first application it finds.  If you want to allow the user to select from a list of applications you can do something like this:

 

void BBMInvocation::shareImageBound()
{

	QString path = QDir::current().absoluteFilePath("shared/photos/avatar.png");

	m_pInvocation = Invocation::create(
			InvokeQuery::create().parent(this).mimeType("image/png").uri(
					QUrl::fromLocalFile(path)));

	QObject::connect(m_pInvocation, SIGNAL(armed()), this, SLOT(onArmed()));

	QObject::connect(m_pInvocation, SIGNAL(finished()), m_pInvocation,
			SLOT(deleteLater()));

}

void BBMInvocation::onArmed()
{
	m_pInvocation->trigger("bb.action.SHARE");
}

 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Sharing a PNG image file only shows "BBM Group"

Trying to replicate this and getting back the following error

'm_pInvocation' was not declared in this
scope

on the line with "m_pInvocation = Invocation::create"

Any idea what I might be doing wrong?
_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Posts: 271
Registered: ‎05-29-2013
My Device: BlackBerry Z10
My Carrier: MTS

Re: Sharing a PNG image file only shows "BBM Group"

m_pInvocation is a class private member with type Invocation *
You can give this variable another name and declare it elsewhere.
-------------------------------------------------------------------------------
NSR Reader for BlackBerry 10 @NSRReader on Twitter
Me @xelfium on Twitter