当从设备发送短信时,以下代码应打印出一条消息。我已经在模拟器上尝试了几次,但是当我发送短信时什么都没有打印出来。我究竟做错了什么?为什么应用程序没有收到已发送的短信。
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.Message message) {
System.out.println("SMS just sent from your device!");
}
}