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

Java Development

Reply
Highlighted
i7
New Contributor
Posts: 2
Registered: ‎09-05-2011
My Device: Curve 8520
My Carrier: TSTT

Accessing/Creating "Send To" Menu

Hi,

I noticed that the Send To menu is pretty ubiquitous for apps on my bb.  Also, as new apps are added, they can be "sent to" from apps that are already on the phone, case in point the Browser App, Twitter and Facebook.

 

I'd like to enable access to this menu for my own apps, so they can "Send To" BBM, Email, Twitter, Facebook and other registered applications.

 

How can this be done?

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

Re: Accessing/Creating "Send To" Menu

Have a look at the sendmediademo included in the BlackBerry Java SDK and BlackBerry JDE for an example.  You can view documentation on this sample here:  http://docs.blackberry.com/en/developers/deliverables/7954/index.jsp?name=Send+Media+Sample+Applicat...

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
i7
New Contributor
Posts: 2
Registered: ‎09-05-2011
My Device: Curve 8520
My Carrier: TSTT

Re: Accessing/Creating "Send To" Menu

@Mark, you rock!

I've made some headway, however, when I call Invoke, I'm getting a null pointer.  What I'm trying to do is take a string and send it to the relevant applications.  Here's what I have so far:

 

public Menu getMenu(int instance) {
		Menu menu =  super.getMenu(instance);
		
		final Registry reg = Registry.getRegistry(CLASSNAME);
		ContentHandler[] handles = reg.forAction(ContentHandler.ACTION_SEND);
		
		
		for (int i=0;i<handles.length;i++)
		{
			String name = handles[i].getAppName();
			String test = "";
			final Invocation inv = new Invocation();
			inv.setURL(sendToUrl);
			inv.setResponseRequired(false);
			inv.setType(handles[i].getType(0));
			inv.setID(handles[i].getID());
			inv.setData(sendToUrl.getBytes());
			inv.setAction(handles[i].getAction(0));
			inv.setArgs(new String[]{sendToUrl});
			
			
			MenuItem mit = new MenuItem(new StringProvider(name), i, i)
			{
				public void run() {
					try {
						reg.invoke(inv);
						//inv.open(false);
					} catch (SecurityException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}	
				}
			};
			
			//ContentHandlerMenu contentHandlerMenu 
			//= new ContentHandlerMenu(inv, reg, "Send to "+ name, i,i);
			
			//menu.add(contentHandlerMenu);
			menu.add(mit);
		}
		return menu;
		
	}

 

 

When I invoke it, i get a NullPointerException:

Thread [net_rim_bb_sendusingbluetoothapp(247)id=200410112] (Suspended (exception NullPointerException))
SendUsingBluetoothContentHandlerApp(AbstractContentHandlerApp).invokeVerbOnCallingApp(Verb, Object, String) line: 104
SendUsingBluetoothContentHandlerApp.invocationRequestNotify(ContentHandlerServer) line: 54
ContentHandlerServerImpl$1.run() line: 258
SendUsingBluetoothContentHandlerApp(Application).dispatchInvokeLater(Runnable, Object, int) line: 1537
SendUsingBluetoothContentHandlerApp(Application).doProcessNextMessage(Message) line: 2205
SendUsingBluetoothContentHandlerApp(Application).processNextMessage(Message) line: 1639
SendUsingBluetoothContentHandlerApp(Application).enterEventDispatcher() line: 1452
SendUsingBluetoothContentHandlerApp(AbstractContentHandlerApp).run() line: 40
SendUsingBluetoothContentHandlerApp.main(String[]) line: 23

 

The App is being built for BB OS 6+

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

Re: Accessing/Creating &quot;Send To&quot; Menu

What line is triggering the exception?  Is it the calling or receiving applicaiton?  Can you provide an example value of sendToUrl you are testing with?

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