OutboundMessageListener doesn't detect outgoing sms
Hi, the following piece of code should print out a message when an sms is sent from the device. I've tried it several times on the simulator but nothing gets printed when I send an sms. What am I doing wrong? Why doesn't the app pick up that an sms has been sent?
public class BackGroundApp extends UiApplication implements OutboundMessageListener, javax.wireless.messaging.MessageListener { private MessageConnection messageConnection; public static void main(String args[]) { BackGroundApp theApp = new BackGroundApp(); theApp.enterEventDispatcher(); } public BackGroundApp(){ try { MessageConnection _mc = (MessageConnection)Connector.open("sms://"); _mc.setMessageListener(this); } catch (IOException e) {} } public void notifyIncomingMessage(MessageConnection messageconnection){ } public void notifyOutgoingMessage(javax.wireless.messaging.Mes sage message) { System.out.println("SMS just sent from your device!"); } } |
Re: OutboundMessageListener doesn't detect outgoing sms
1. You need to register your listener with the MessageConnection per the API documentation.
2. The simulator can't really send SMS messages so you may have to do this on a device. |
All times are GMT -5. The time now is 03:32 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.