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
Developer
Posts: 246
Registered: ‎03-14-2012
My Device: PlayBook 2.0
My Carrier: AT&T

Enable Share button in context menu

Hi,

 

How to enable the Share button in the context menu?

http://developer.blackberry.com/air/files/documentation/images/invocation_context_menu.png

 

Does anybody have an working example for Air? Smiley Happy

 

Thank you

Developer
Posts: 1,269
Registered: ‎12-29-2010
My Device: PlayBook, Z10 LE, Dev Alpha C

Re: Enable Share button in context menu

This might get you going if you haven't seen it yet:

 

https://developer.blackberry.com/air/documentation/menus.html

Developer
Posts: 246
Registered: ‎03-14-2012
My Device: PlayBook 2.0
My Carrier: AT&T

Re: Enable Share button in context menu

I can't get it to work from the documentation! Smiley Sad

Is there a working Air example with source code available?

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Enable Share button in context menu

Are you able to get the context menu working? Or is this an issue in how to create an invocation?
BlackBerry Development Advisor
Posts: 172
Registered: ‎10-25-2010
My Device: Not Specified

Re: Enable Share button in context menu

The following sample should work. It is important to remember that there needs to be a target to share with on the device for something to appear.

 

var ba:ByteArray = new ByteArray();
ba.writeUTFBytes( "Some text to share" );

var button:Button = new Button();
//When using the InvokeActionItem class, ensure your application is including the QNXDevice.ane. 
var invokeItem:InvokeActionItem = new InvokeActionItem( null, "text/plain", null, ba );
var actionSet:ActionSet = new ActionSet( new <ActionBase>[invokeItem] );
var actions:Vector.<ActionSet> = new <ActionSet>[actionSet];
button.contextActions  = actions;
			
addChild( button );

 

Note that this will give you all of the options for the mimeType. You can substitute the first parameter with a share action to only get Share.

Developer
Posts: 246
Registered: ‎03-14-2012
My Device: PlayBook 2.0
My Carrier: AT&T

Re: Enable Share button in context menu

[ Edited ]

I tried the example but I'm running into this error:

"error 1172: Definition qnx:InvokeActionItem not found"

 

I added the QNXDevice.ane - do I need to add another one?
How to fix that?

 

Thank you.

BlackBerry Development Advisor
Posts: 172
Registered: ‎10-25-2010
My Device: Not Specified

Re: Enable Share button in context menu

You need to make sure that you package the ANE as well.

 

Assuming you are using Flash Builder

https://developer.blackberry.com/air/documentation/add_ane_fb.html

 

 

Developer
Posts: 246
Registered: ‎03-14-2012
My Device: PlayBook 2.0
My Carrier: AT&T

Re: Enable Share button in context menu

I added the QNXDevice.ane but still getting the error.

Do I need to import classes or something?

BlackBerry Development Advisor
Posts: 172
Registered: ‎10-25-2010
My Device: Not Specified

Re: Enable Share button in context menu

Yes you need to import any class that you are referencing.

 

import qnx.fuse.ui.core.InvokeActionItem;

 

Should be able to simply do an auto-complete to get any missing import.

Developer
Developer
Posts: 227
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: Enable Share button in context menu

Julian;

 

Thanks for the example code - I did learn something.  However, I'm still having a (different) problem:

 

If I queryInvokeTargets for a given file, VIEW, OPEN and SHARE targets are returned.

I I create a new InvokeActionItem for the same file, only the SHARE targets are returned.

 

I'd hoped that moving to 10.2 (SDK and simulator) would resolve this issue, but seems unchanged.

 

The invokeManager debug output is shown below:

info: app: InvokeManager: [qnx.pps.Message(queryInvokeTargets dat: {
	uri : file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120902-00079.jpg
	type : */*
	target_type_mask : 0
}, peer : null, error : null, id: null, result: null]
info: app: InvokeManager: QUERY TARGETS RESPONSE [qnx.pps.Message(queryInvokeTargets dat: {
	0 : {
		action : bb.action.SHARE
		label : Share
		targets : {
			0 : {
				label : Meeting Participants
				perimeter : personal
				type : CARD
				uri_match : file://
				key : sys.pim.calendar.viewer.nav
				icon : /apps/sys.pim.calendar.viewer.nav.gYABgPIA0trhylSMg77RTmTfg8s/public/native/icon.png
			}
			1 : {
				label : Bluetooth
				perimeter : personal
				type : CARD
				uri_match : file://
				key : sys.btviewer
				icon : /apps/sys.btviewer.gYABgJSFvQk7U5eBFvuKFzo01iM/public/native/icon.png
			}
			2 : {
				label : BBM
				perimeter : personal
				type : CARD
				uri_match : file://
				key : sys.bbm.sharehandler
				icon : /apps/sys.bbm.gYABgLOJBR2Vz7FzS.kdgJchuag/public/native/bbmtarget.png
			}
			3 : {
				label : NFC
				perimeter : personal
				type : CARD
				uri_match : *
				key : sys.NFCViewer
				icon : /apps/sys.NFCViewer.gYABgFfBGdAX03rWRgo77YVGewg/public/native/icon.png
			}
		}
		icon : /usr/share/icons/bb_action_share.png
		default : sys.pim.calendar.viewer.nav
	}
	1 : {
		action : bb.action.VIEW
		label : 
		targets : {
			0 : {
				label : Pictures Previewer
				perimeter : personal
				type : APPLICATION
				uri_match : file://
				key : sys.pictures.previewer.app
				icon : /apps/sys.picturesviewer.gYABgFKlvDBH.tdV7sGqIDZHnNY/public/native/icon.png
			}
			1 : {
				label : Pictures Previewer
				perimeter : personal
				type : CARD
				uri_match : file://
				key : sys.pictures.card.previewer
				icon : /apps/sys.picturesviewer.gYABgFKlvDBH.tdV7sGqIDZHnNY/public/native/icon.png
			}
		}
		icon : 
		default : sys.pictures.previewer.app
	}
	2 : {
		action : bb.action.OPEN
		label : Open in
		targets : {
			0 : {
				label : Pictures Previewer
				perimeter : personal
				type : APPLICATION
				uri_match : file://
				key : sys.pictures.previewer.app
				icon : /apps/sys.picturesviewer.gYABgFKlvDBH.tdV7sGqIDZHnNY/public/native/icon.png
			}
		}
		icon : /usr/share/icons/bb_action_open.png
		default : sys.pictures.previewer.app
	}
	3 : {
		action : bb.action.nfc.writetag
		label : 
		targets : {
			0 : {
				label : NFC
				perimeter : personal
				type : CARD
				uri_match : *
				key : sys.NFCViewer
				icon : /apps/sys.NFCViewer.gYABgFfBGdAX03rWRgo77YVGewg/public/native/icon.png
			}
		}
		icon : 
		default : sys.NFCViewer
	}
}, peer : @control, error : null, id: 2, result: queryInvokeTargets]
info: app: InvokeManager: getMenuItems function Function() {}
info: app: InvokeManager: [qnx.pps.Message(getMenuItems dat: {
	uri : file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120902-00079.jpg
	mime : */*
	target_type_mask : 3
}, peer : null, error : null, id: null, result: null]
info: app: InvokeManager: [qnx.pps.Message(getMenuItems dat: {
	items : {
		0 : {
			item-type : 0
			label : Share
			icon : /usr/share/icons/bb_action_share.png
			invoke : {
				item-type : 0
				uri : file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120902-00079.jpg
				type : CARD
				action : bb.action.SHARE
				label : Share
				icon : /usr/share/icons/bb_action_share.png
				mime : */*
				metadata &colon; {"menuservice":"115367306543250,2"}
				target : sys.invokeTargetSelection
			}
		}
	}
}, peer : @control, error : null, id: 2, result: getMenuItems]