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
Contributor
Posts: 14
Registered: ‎05-17-2013
My Device: Dev Alpha B/C, PlayBook
My Carrier: Vodafone
Accepted Solution

How to invoke the BlackBerry Share menu form an Adobe Air app?

Hello,

I'm looking for a tutorial or demo code that describes how to invoke the BlackBerry Share menu from an Adobe Air based app.

I found a Cascades tutorial for it - is there one for Adobe Air too?
- http://bbcascadescode.tumblr.com/post/38998702671/invoke-share-for-bb10

 

This is a screenshot of the Share menu:

 

Any tips welcome! :smileyhappy:

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

Re: How to invoke the BlackBerry Share menu form an Adobe Air app?

At the time, I could not find a way, so I wrote my own using the invocation framework to fill in the information. It's not too hard and give you a little more control.
Contributor
Posts: 14
Registered: ‎05-17-2013
My Device: Dev Alpha B/C, PlayBook
My Carrier: Vodafone

Re: How to invoke the BlackBerry Share menu form an Adobe Air app?

Can you please share your code with me? :smileyhappy:

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

Re: How to invoke the BlackBerry Share menu form an Adobe Air app?

Here you go:

package com.lib.playbook.invocation
{
	import com.lib.playbook.controls.List;
	import com.lib.playbook.pages.TitlePage;
	import com.lib.playbook.renderers.IconListRenderer;
	
	import flash.events.Event;
	import flash.events.IEventDispatcher;
	
	import qnx.events.InvokeEvent;
	import qnx.events.InvokeQueryTargetEvent;
	import qnx.fuse.ui.core.Action;
	import qnx.fuse.ui.events.ActionEvent;
	import qnx.fuse.ui.events.ListEvent;
	import qnx.invoke.ActionQuery;
	import qnx.invoke.InvokeManager;
	import qnx.invoke.InvokeRequest;
	import qnx.invoke.InvokeTarget;
	
	public class InvokeSearchPage extends TitlePage
	{
		private var request : InvokeRequest = null;
		private var targets : List = new List();
		
		/////////////////////////////////////////////////////////////////////////////////////////
		public function InvokeSearchPage()
		{
			super();
			this.title = 'Search With';
			this.titlebar.dismissAction = new Action( 'Cancel', null, {id:'cancel'} );
			this.titlebar.addEventListener(ActionEvent.ACTION_SELECTED, ActionSelected );
			
			this.targets.cellRenderer = com.lib.playbook.renderers.IconListRenderer;
			this.targets.addEventListener(ListEvent.ITEM_CLICKED, TargetSelected );
            this.targets.rowHeight = 140;
			this.addChild( this.targets );
		}
		
		///////////////////////////////////////////////////////////////////////////////////////////
		public function filter( request :InvokeRequest ) : void
		{
			this.targets.removeAll();
			
			this.request = request;
			
			//trace( 'filter ' + request.mimeType );
			InvokeManager.invokeManager.addEventListener( InvokeQueryTargetEvent.SUCCESS, TargetsFound );
			InvokeManager.invokeManager.queryInvokeTargets( request.mimeType, request.uri, request.action, request.targetOptions );
		}
		
		///////////////////////////////////////////////////////////////////////////////////////////
		private function TargetsFound( event : InvokeQueryTargetEvent ) : void
		{
			InvokeManager.invokeManager.removeEventListener(InvokeQueryTargetEvent.SUCCESS, TargetsFound );
			//trace( 'TargetsFound' );
			var action : ActionQuery;
			var target : InvokeTarget;
			for each( action in event.actions )
			{	
			    for each( target in action.targets )
				{
				  this.targets.addItem( { data : target.target, label : target.label, icon : 'file://' + target.icon } );
				}
			}
		}
		
		////////////////////////////////////////////////////////////////////
		private function TargetSelected( event :Event ) : void
		{
            if( this.targets.selectedIndex >= 0 )
            {
			  this.request.target = this.targets.selection;
			  InvokeManager.invokeManager.invoke( this.request );
            }
		}
		
		////////////////////////////////////////////////////////////////////
		private function ActionSelected( event :ActionEvent ) : void
		{
			switch( event.action.data.id )
			{
				case 'cancel' : this.dispatchEvent( new Event( Event.CANCEL ) ); break;
			}
		}
		
		//////////////////////////////////////////////////////////////////////
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
		{
			super.updateDisplayList( unscaledWidth, unscaledHeight );
			
			this.targets.setPosition( 10, this.top + 10 );
			this.targets.setActualSize( unscaledWidth - 20, unscaledHeight - this.targets.y - 10 );
		}
	}
}

 And renderer:

package com.lib.playbook.renderers
{
	

	import qnx.fuse.ui.display.Image;
	import qnx.fuse.ui.listClasses.CellRenderer;
	
	public class IconListRenderer extends CellRenderer
	{
		
		private var icon    :Image = new Image();

		/////////////////////////////////////////////////////////////////////////
		public function IconListRenderer()
		{
			super();	
		}
		
		///////////////////////////////////////////////////////////////
		override protected function onAdded():void
		{
			super.onAdded();
			this.addChild( this.icon );
		}
		
		///////////////////////////////////////////////////////////////
		override protected function onRemoved():void
		{
			super.onRemoved();
			this.removeChild( this.icon );
		}
		

		/////////////////////////////////////////////////////////////////////////////////////
		override protected function drawLabel(unscaledWidth:Number, unscaledHeight:Number):void
		{
			super.drawLabel( unscaledWidth, unscaledHeight );

			if( this.data )
			{
			
				if( this.data.hasOwnProperty( 'icon' ) && this.data.icon != null )
				{
					this.icon.setImage( this.data.icon );
					this.icon.setPosition( 10, 15 );//( unscaledHeight - this.icon.height ) / 2 );
				}
				else
				{
					this.icon.setImage( null );
				}
				
			}

			this.label.x = 140;
			this.label.width = unscaledWidth - this.label.x - 20;
		}
	}
}

 the com.lib.playbook references our our internal classes, but you should get the approach to apply.

Contributor
Posts: 14
Registered: ‎05-17-2013
My Device: Dev Alpha B/C, PlayBook
My Carrier: Vodafone

Re: How to invoke the BlackBerry Share menu form an Adobe Air app?

Sorry, that is not what I'm looking for.

The code below is in Cascades - what does one need to change to use it in BB10 app build with Adobe Air?

 

actions: [
InvokeActionItem {
ActionBar.placement: ActionBarPlacement.OnBar
title: "Share"
query {
mimeType: "text/plain"
invokeActionId: "bb.action.SHARE"
}
onTriggered: {

}
}
]

 Thanks! :smileyhappy:

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

Re: How to invoke the BlackBerry Share menu form an Adobe Air app?

You need to use the invocation classes that are in the BB SDK. The names match most of what is in the Cascades JSON. The API documentation has more on this.
Contributor
Posts: 14
Registered: ‎05-17-2013
My Device: Dev Alpha B/C, PlayBook
My Carrier: Vodafone

Re: How to invoke the BlackBerry Share menu form an Adobe Air app?

[ Edited ]

Below is the code I tried.
I have no idea why a dialog with "Select a BBM Group" comes up instead of the BlackBerry share menu. 

How to invoke the BlackBerry share menu?

import qnx.events.InvokeEvent;
import qnx.invoke.*;

import qnx.fuse.ui.core.InvokeActionItem;
import qnx.fuse.ui.core.ActionSet;
import qnx.fuse.ui.core.ActionBase;

import flash.utils.ByteArray;
import flash.events.Event;

function invokeShareMenu(e:Event=null):void {
var ba:ByteArray = new ByteArray();
ba.writeUTFBytes("Test");

var invoke:InvokeTargetOptions = new InvokeTargetOptions();
var request:InvokeRequest = new InvokeRequest();
request.mimeType = "text/plain";

request.targetOptions = InvokeTargetOptions.ALL;
request.action = InvokeAction.SHARE 
request.data = ba;
InvokeManager.invokeManager.invoke(request);
}

 Is it possible at all? There is no example for an Adobe Air based app available.

Thank you

Drean

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

Re: How to invoke the BlackBerry Share menu form an Adobe Air app?

There is a code sample above to create a page and fill a list to choose from. Your code here will invoke the first (or best as decided by the OS) match to your query.
New Member
Posts: 20
Registered: ‎03-27-2014
My Device: none
My Carrier: Docomo

Re: How to invoke the BlackBerry Share menu form an Adobe Air app?

Does it support graphical database ??