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
Developer
Posts: 1,632
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

OutboundSMSListener help

private static final class OutboundSMSListener implements OutboundMessageListener { public void notifyIncomingMessage(MessageConnection messageconnection) { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Dialog.alert("Detected An incoming SMS Event"); } }); } public void notifyOutgoingMessage(Message message) { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Dialog.alert("Detected An Outgoing SMS Event"); } }); } } }

 

the above code works when i get a incoming sms but it does not work when a send a sms.

this is the correct method?

 

this is how i add the listener

 

try { _mc = (MessageConnection)Connector.open("sms://:0"); _mc.setMessageListener(new OutboundSMSListener()); } catch (IOException e) { }

 

 

 

 

 

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: OutboundSMSListener help

I tried this. It worked on Simulator 9000. JDE 4.6.

 

public class BackGroundApp extends Application implements OutboundMessageListener, javax.wireless.messaging.MessageListener { public static void main(String args[]) { BackGroundApp theApp = new BackGroundApp(); theApp.enterEventDispatcher(); } public BackGroundApp() { try { MessageConnection _mc = (MessageConnection)Connector.open("sms://:0"); _mc.setMessageListener(this); } catch (IOException e) { } } public void notifyIncomingMessage(MessageConnection messageconnection) { System.out.println("Coming here in outgoing SMS"); } public void notifyOutgoingMessage(javax.wireless.messaging.Message message) { System.out.println("Coming here in outgoing SMS"); } }

 

 

 


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 1,632
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: OutboundSMSListener help

thanks will try this out.

 

btw, what i need to install to simulate sms ?

 

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: OutboundSMSListener help

Just run the application. Send an SMS from simulator, you can see System.Out. on output window. No need to install any other things.

 


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 1,632
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: OutboundSMSListener help

Quick question.

 

I take it that only one application can use port 0.

 

             MessageConnection _mc = (MessageConnection)Connector.open("sms://:0");


If it use ("sms://")  the listner isnt getting called.

 

is this true?

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: OutboundSMSListener help

Yes, only one application can use MessageListener.

 

You can have multiple applciations listening for SMS if you use the Datagram method.

 

 

 

Developer
Posts: 1,632
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: OutboundSMSListener help

i looked at the datagram but there is no outgoing listener.

do you have an example using datagram for incoming and outgoing sms?

 

thx

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

Re: OutboundSMSListener help

The OutboundMessageListener does not support a DatagramConnection.  A DatagramConnection can be used to send SMS messages and listen for incoming messages only (not listen for outgoing messages).
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: 1,632
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: OutboundSMSListener help

thanks mark.  that is what i thought.

 

is there any reason why only one app can lock sms port 0?

if some other 3rd app has port 0 locked my app can't run.

this is goes for other apps too if my app locks port 0 first.

 

Developer
Posts: 198
Registered: ‎04-03-2009
My Device: Not Specified

Re: OutboundSMSListener help

Hi,

 

How will you simulate incoming message on Simulator.

 

 

Thanks..