当前位置: 代码迷 >> J2ME >> j2me 发送短信,该如何解决
  详细解决方案

j2me 发送短信,该如何解决

热度:3716   发布时间:2013-02-25 21:38:17.0
j2me 发送短信
为什么我的代码在模拟器上都是成功的,而且在手机上发送短信也提示成功,但是就是收不到短信,已发短信里也看不到,麻烦高人指点下:
代码如下
public void run(){  
  boolean result = true;  
  int colonIdx = Number.substring (6).indexOf (":");
  if (colonIdx > 0) {
  Number = Number.substring (0, colonIdx + 6);
  }
  String address = Number + ":" + "50000";

  MessageConnection smsconn = null;
  System.out.println("发送地址为:" + address); 

  try {
  /** Open the message connection. */
  smsconn = (MessageConnection) Connector.open (address);

  TextMessage txtmessage =
  (TextMessage) smsconn.newMessage (MessageConnection.TEXT_MESSAGE);
  txtmessage.setAddress (address);
  txtmessage.setPayloadText (Message);
  smsconn.send (txtmessage);
  }
  catch (Throwable t) {
  System.out.println ("Send caught: ");
  t.printStackTrace ();
  }

  if (smsconn != null) {
  try {
  smsconn.close ();
  }
  catch (IOException ioe) {
  System.out.println ("Closing connection caught: ");
  ioe.printStackTrace ();
  }
  }
  System.out.print("Sent message...........................................................");
  //执行回掉函数
  this.smsCallback.onHandedSms(result);
  }

 PS:端口号没加和加50000结果是一样的,都是提示发送成功就是收不到,和已发短信里也看不到

------解决方案--------------------------------------------------------
smsconn = (MessageConnection) Connector.open (address);
——————
smsconn = (MessageConnection) Connector.open ("sms://+1380000000");