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

Adobe AIR Development

Reply
Highlighted
Developer
Posts: 275
Registered: ‎01-21-2013
My Device: BB10 Dev Aplha
My Carrier: -

Opening Share card

I was able to add the context menu so that it opens the standard Share card using following code:

var oByte:ByteArray = new ByteArray();
oByte.writeUTFBytes(sShareMessage);
var invokeItem:InvokeActionItem = new InvokeActionItem(InvokeAction.SHARE,"text/plain",'',oByte);
var actionSet:ActionSet = new ActionSet(new <ActionBase>[invokeItem]);
var actions:Vector.<ActionSet> = new <ActionSet>[actionSet];
oButton.contextActions = actions;

 But I have a Share button on Action Bar and I want to open the standrad Share card, but it is not getting opened. I even tried with the following code but it always open Share as BBM and does not provide the Share card, where all Share options are listed:

var data&colon;ByteArray = new ByteArray();
data.writeUTFBytes(sShareMessage);
var request:InvokeRequest = new InvokeRequest();
request.action = InvokeAction.SHARE;
request.mimeType = 'text/plain';
request.data = data;				InvokeManager.invokeManager.invoke(request);

 

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Opening Share card

You are performing an unbound invocation.  When doing an unbound invocation, you allow the invocation framework to choose a target for you that can handle the content you are using.

 

If you want the share card to appear, which allows the user to select the application you need to perform a bound invocation without specifying the target.  

 

You can read more about bound and unbound invocation here:  Sending invocation

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: 275
Registered: ‎01-21-2013
My Device: BB10 Dev Aplha
My Carrier: -

Re: Opening Share card

I guess performing bound invocation without target is itself unbound invocation. And that is what I had done in the code, but as said, the invocation framework decides and chooses only one traget and does not give me options of all Share-able applications, as done in context code example.

 

I read through the article but was unable to open the Share card.

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Opening Share card

Bound invocation without a target is different than unbound invocation.

 

Unbound invocation (which you are using):

 

bb::system::InvokeManager invokeManager;

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

	bb::system::InvokeRequest request;
	request.setAction("bb.action.SHARE");

	request.setUri(QUrl::fromLocalFile(path));
	bb::system::InvokeTargetReply *reply = invokeManager.invoke(request);

 

Bound invocation without a target:

 

	QString path = QDir::current().absoluteFilePath("shared/photos/background.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()));

}

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: 275
Registered: ‎01-21-2013
My Device: BB10 Dev Aplha
My Carrier: -

Re: Opening Share card

How can I get the intended functionality wherein it will automatically show all sharable applications on device?

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Opening Share card

Use the second code snippet I posted.

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: 275
Registered: ‎01-21-2013
My Device: BB10 Dev Aplha
My Carrier: -

Re: Opening Share card

Hi Mark,

 

Thanks for the code, is this AIR actionscript code, I guess this is native code and I could not locate corresponding action-script code.

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Opening Share card

Sorry, mixed up which forum I was replying in here.  This feature isn't available in AIR applications, only native Cascades applications.

 

You could query targets and present the list to the user.  But you'd have to create your own UI for that.

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: 275
Registered: ‎01-21-2013
My Device: BB10 Dev Aplha
My Carrier: -

Re: Opening Share card

I was able to create the query and corresponding UI in order to show the Share Card.

 

However the query returns only one item for all the email accounts and I can not show seperate Email accounts in the Share Card, which is done by default Share functionality:

 

What I get is something following using Query Code:

Email

 

What I get using default Share functinality:

Gmail

dummy@gmail.com

 

Rediffmail

dummy@rediffmail.com

 

Corporate

dummy@Corporate.com

 

Is it possible to get the Email accounts details and also so launch the email card with only selected Email Account?

 

 

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Opening Share card

Yes, you can trigger the invocation to a specific email account.  You can specify the email account ID in the from section of the JSON you are using to construct the message.

 

From invoking email:

 


Data should be sent in JSON format, as shown below:

{
  "to" : ["a@a.com", "b@b.net"],
  "from" : 1234,
  "cc" : ["foo@bar.com", "stuff@place.com"],
  "bcc" : ["foo@bar.com", "stuff@place.com"],
  "subject" : "Some punctuation. Symbol in the $ubject!!",
  "body" : "HI! Here is some more stuff.\n\n14% of emails have #1 newline or
stuff* @ home.\n",
  "attachment" : ["file:///path/to/my/item.txt"]
}

 

The from field in the code above represents the account ID that is used as a default value for the composer card.


 

 

 

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