问一个关与 J2ME 发送短消息的问提, 新手求救!!

在模拟欺上器上测试的时候能用, 但是装到手机上就不能用了。按了START 后没有反应,而且连那个确认的提示都没有。

请高手帮忙看看, 我把所有代码都贴出来了。

package main;

import javax.microedition.midlet.*;
import javax.microedition.io.*;
import javax.wireless.messaging.*;


public class Main extends MIDlet implements CommandListener {

String payload = "123_ABC";

SmsTransmitter tx;
Thread txThread;

TextBox tbox;
Command smsCommand;
Command exitCommand;

/**
 * Constructor
 */
public Main () {
//-- init GUI
tbox = new TextBox("Test-SMS-MIDlet", "Sends an SMS with content '"+payload+"'.", 999, 0);

//-- init Commands
smsCommand = new Command("Start", Command.SCREEN, 1);
exitCommand = new Command("Exit", Command.EXIT, 3);

//-- add Commands to GUI
tbox.addCommand(smsCommand);
tbox.addCommand(exitCommand);


//-- start CommadListener
tbox.setCommandListener(this);
}

public void startApp() {
javax.microedition.lcdui.Display.getDisplay(this).setCurrent(tbox);
}


public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command cmd, Displayable disp) {
if (cmd == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
else if (cmd == smsCommand) {

tx = new SmsTransmitter();
txThread = new Thread(tx);
txThread.start();
}
}


class SmsTransmitter implements Runnable {
public void run() {
MessageConnection mc=null;
TextMessage sosMsg=null;
try {
mc = (MessageConnection) Connector.open("sms://+4917620555153");
sosMsg = (TextMessage)mc.newMessage(MessageConnection.TEXT_MESSAGE);
sosMsg.setPayloadText(payload);
mc.send(sosMsg);
}
catch(Exception e) {
e.printStackTrace();
}

} }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值