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
Deevych
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified

BB10 Share action for image

Hello,

 

I'm trying to add a Share action item to context actions and it seems to be somewhat working, but...

 

The app is supposed to take a screenshot (of itself) and share it via registered apps/services for jpg or png image.

I ended up with Share icon in my Context actions that is showing Share dialog with BBM, BBM Group, Bluetooth and NFC. The problem is that I can't pass a screenshot to invoke action data.

 

Here is the code I'm using:

var invokeItem:InvokeActionItem = new InvokeActionItem(InvokeAction.SHARE, "image/png", "file://" + StorageUtils.getScreenshotPath()); 
actionSet.actions = new <ActionBase>[invokeItem];

When invoke action is selected, I'm taking a screenshot and saving it to the file as stated above.

But when the Share dalog opened the shared file is empty.

 

I even tried to re-set the file path to .data property, and jus for fun tried setting a ByteArray that was saved to file. No  luck.

 

One more issue - when I remove the last param ("file://...") from InvokeActionItem contructor, selecting of Share action immediately opens NFC option. But again, no file or data shared.

 

So, any working solution for images sharing? I could find samples for texts, but none for files or images in memory.

 

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10 Share action for image

Do you have a timing issue? Is the menu being created before the image has finished being saved? A screen shot can take ~1 sec to complete.
Please use plain text.
Developer
Deevych
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified

Re: BB10 Share action for image

[ Edited ]

Yes, I expecting to have the delay with screenshot (even more than a second as I'm using JPG/PNGEncoder to minimize the output size), but even next time I select the action (file already created) the problem still persists.

 

For delay, I was thinking also about a way to override the .data property for InvokeActionItem so it has a correct data, but I still could not find the solution.

Please use plain text.
Developer
Deevych
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified

Re: BB10 Share action for image

And so, am I the only one who's trying to share image on BB10? :smileyhappy:
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10 Share action for image

Just give the URI to the image file as part of the invocation.
Please use plain text.
Developer
Developer
mdd
Posts: 224
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: BB10 Share action for image

I'm encountering the same issue.  Was a solution found?

 

Since we aren't doing the actual invokation directly (its done by the context menu), we can't set the URI.  I did try setting the data attribute:

bytes.writeUTFBytes( JSON.stringify( { uri: file.url } ) );

 but that text then appears in the BBM message...  pdf and doc files say "file not found".

 

Since each app (email, text, bbm, etc.) takes various forms of data, I'm wondering how this can work.

Please use plain text.
Developer
Developer
CMY
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: BB10 Share action for image

I've run into this issue when testing the share feature, and if you pass an invalid parameter, then its shows it in the BBM text. One thing that stands out with your code is that you don't have the "file://" prefix before the file url. The url does not return "file://" as part of the path.
Please use plain text.
Developer
Developer
mdd
Posts: 224
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: BB10 Share action for image

Somewhat off topic, butstill  relates to using InvokeActionItem to populate a contextMenu:

 

Tested on latest simulator (10.1.0.1483).

 

I'm first using queryInvokeTargets to look for an invokable OPEN or VIEW action, then creating the InvokeActionItem for an image file for OPEN, VIEW and SHARE.

 

Below, the InvokeManager.DEBUG output:

info: app: InvokeManager: [qnx.pps.Message(queryInvokeTargets dat: {
	target_type_mask : 0
	uri : file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120512-00015.jpg
}, peer : null, error : null, id: null, result: null]
info: app: InvokeManager: QUERY TARGETS RESPONSE [qnx.pps.Message(queryInvokeTargets dat: {
	0 : {
		default : sys.navigator.wallpaper
		icon : /usr/share/icons/bb_action_set.png
		label : Set As
		action : bb.action.SET
		targets : {
			0 : {
				type : SERVICE
				key : sys.navigator.wallpaper
				icon : /usr/share/icons/set_as_wallpaper.png
				label : Wallpaper
				perimeter : personal
			}
			1 : {
				type : CARD
				key : sys.bbm.imagehandler
				icon : /apps/sys.bbm.gYABgLOJBR2Vz7FzS.kdgJchuag/public/native/bbmtarget.png
				label : BBM Picture
				perimeter : personal
			}
			2 : {
				type : CARD
				key : sys.pim.contacts.setcontactpicture
				icon : /apps/sys.pim.contacts.gYABgGsAOuzqCT1fu5Zx4sqrJdY/public/native/assets/images/ca_contacts.png
				label : Contact Picture
				perimeter : personal
			}
		}
	}
	1 : {
		default : sys.bbgroups.sharehandler
		icon : /usr/share/icons/bb_action_share.png
		label : Share
		action : bb.action.SHARE
		targets : {
			0 : {
				type : CARD
				key : sys.bbgroups.sharehandler
				icon : /apps/sys.bbm.gYABgLOJBR2Vz7FzS.kdgJchuag/public/native/ca_bbm_groups.png
				label : BBM Group
				perimeter : personal
			}
			1 : {
				type : CARD
				key : sys.NFCViewer
				icon : /apps/sys.NFCViewer.gYABgFfBGdAX03rWRgo77YVGewg/public/native/icon.png
				label : NFC
				perimeter : personal
			}
			2 : {
				type : CARD
				key : sys.bbm.sharehandler
				icon : /apps/sys.bbm.gYABgLOJBR2Vz7FzS.kdgJchuag/public/native/bbmtarget.png
				label : BBM
				perimeter : personal
			}
			3 : {
				type : CARD
				key : sys.pim.remember.composer
				icon : /apps/sys.pim.remember.gYABgF9PcqaN7GRKPlDPuqOyda0/public/native/icon_share.png
				label : Remember
				perimeter : personal
			}
		}
	}
	2 : {
		default : sys.pictureeditor.cardeditor
		icon : 
		label : 
		action : bb.action.EDIT
		targets : {
			0 : {
				type : CARD
				key : sys.pictureeditor.cardeditor
				icon : /apps/sys.pictureeditor.gYABgIRm37_owYKt4P0uCEhSj.o/public/native/icon.png
				label : Picture Editor
				perimeter : personal
			}
		}
	}
	3 : {
		default : sys.pictures.previewer.app
		icon : 
		label : 
		action : bb.action.VIEW
		targets : {
			0 : {
				type : APPLICATION
				key : sys.pictures.previewer.app
				icon : /apps/sys.picturesviewer.gYABgFKlvDBH.tdV7sGqIDZHnNY/public/native/icon.png
				label : Pictures Previewer
				perimeter : personal
			}
			1 : {
				type : CARD
				key : sys.pictures.card.previewer
				icon : /apps/sys.picturesviewer.gYABgFKlvDBH.tdV7sGqIDZHnNY/public/native/icon.png
				label : Pictures Previewer
				perimeter : personal
			}
		}
	}
	4 : {
		default : sys.NFCViewer
		icon : 
		label : 
		action : bb.action.nfc.writetag
		targets : {
			0 : {
				type : CARD
				key : sys.NFCViewer
				icon : /apps/sys.NFCViewer.gYABgFfBGdAX03rWRgo77YVGewg/public/native/icon.png
				label : NFC
				perimeter : personal
			}
		}
	}
}, peer : @control, error : null, id: 12, result: queryInvokeTargets]
start trace output:
getInvokableActions: null file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120512-00015.jpg bb.action.OPEN,bb.action.VIEW action: Set As = bb.action.SET sys.navigator.wallpaper nTargets: 3 action: Share = bb.action.SHARE sys.bbgroups.sharehandler nTargets: 4 action: = bb.action.EDIT sys.pictureeditor.cardeditor nTargets: 1 action: = bb.action.VIEW sys.pictures.previewer.app nTargets: 2 target: sys.pictures.previewer.app label: 'Pictures Previewer' Type: APPLICATION icon: /apps/sys.picturesviewer.gYABgFKlvDBH.tdV7sGqIDZHnNY/public/native/icon.png target: sys.pictures.card.previewer label: 'Pictures Previewer' Type: CARD icon: /apps/sys.picturesviewer.gYABgFKlvDBH.tdV7sGqIDZHnNY/public/native/icon.png action: = bb.action.nfc.writetag sys.NFCViewer nTargets: 1 haveQueryResponse: IMG-20120512-00015.jpg true end trace output
info: app: InvokeManager: getMenuItems function Function() {} info: app: InvokeManager: [qnx.pps.Message(getMenuItems dat: { target_type_mask : 3 uri : file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120512-00015.jpg action : bb.action.SHARE }, peer : null, error : null, id: null, result: null] info: app: InvokeManager: [qnx.pps.Message(getMenuItems dat: { items : { 0 : { children : { title : Share items : { 0 : { invoke : { uri : file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120512-00015.jpg label : BBM target : sys.bbm.sharehandler type : CARD icon : /apps/sys.bbm.gYABgLOJBR2Vz7FzS.kdgJchuag/public/native/bbmtarget.png perimeter : personal action : bb.action.SHARE } icon : /apps/sys.bbm.gYABgLOJBR2Vz7FzS.kdgJchuag/public/native/bbmtarget.png label : BBM } 1 : { invoke : { uri : file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120512-00015.jpg label : BBM Group target : sys.bbgroups.sharehandler type : CARD icon : /apps/sys.bbm.gYABgLOJBR2Vz7FzS.kdgJchuag/public/native/ca_bbm_groups.png perimeter : personal action : bb.action.SHARE } icon : /apps/sys.bbm.gYABgLOJBR2Vz7FzS.kdgJchuag/public/native/ca_bbm_groups.png label : BBM Group } 2 : { invoke : { uri : file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120512-00015.jpg label : NFC target : sys.NFCViewer type : CARD icon : /apps/sys.NFCViewer.gYABgFfBGdAX03rWRgo77YVGewg/public/native/icon.png perimeter : personal action : bb.action.SHARE } icon : /apps/sys.NFCViewer.gYABgFfBGdAX03rWRgo77YVGewg/public/native/icon.png label : NFC } 3 : { invoke : { uri : file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120512-00015.jpg label : Remember target : sys.pim.remember.composer type : CARD icon : /apps/sys.pim.remember.gYABgF9PcqaN7GRKPlDPuqOyda0/public/native/icon_share.png perimeter : personal action : bb.action.SHARE } icon : /apps/sys.pim.remember.gYABgF9PcqaN7GRKPlDPuqOyda0/public/native/icon_share.png label : Remember } } } icon : /usr/share/icons/bb_action_share.png label : Share } } }, peer : @control, error : null, id: 34, result: getMenuItems] checkComplete: IMG-20120512-00015.jpg bb.action.SHARE found: 1 info: app: InvokeManager: getMenuItems function Function() {} info: app: InvokeManager: [qnx.pps.Message(getMenuItems dat: { target_type_mask : 3 uri : file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120512-00015.jpg action : bb.action.VIEW }, peer : null, error : null, id: null, result: null] info: app: InvokeManager: [qnx.pps.Message(getMenuItems dat: { }, peer : @control, error : null, id: 35, result: getMenuItems] checkComplete: IMG-20120512-00015.jpg bb.action.VIEW found: 0 info: app: InvokeManager: getMenuItems function Function() {} info: app: InvokeManager: [qnx.pps.Message(getMenuItems dat: { target_type_mask : 3 uri : file:///accounts/1000/appdata/MyTonido.debug.testDev_onido_debug60b05a92/shared/photos/IMG-20120512-00015.jpg action : bb.action.OPEN }, peer : null, error : null, id: null, result: null] info: app: InvokeManager: [qnx.pps.Message(getMenuItems dat: { }, peer : @control, error : null, id: 36, result: getMenuItems] checkComplete: IMG-20120512-00015.jpg bb.action.OPEN found: 0

First, note that the uri DOES include the "file:///" prefix, so that's not the problem.

 

Note that queryInvokeTargets shows both SHARE and VIEW targets (CARD=2 and APPLICATION=1), but InvokableActionItem finds no targets for VIEW (mask = 3 = 2+1).

 

Also, I ensure that the requests are all serialized.

 

Suggestions.

Please use plain text.