在用j2me发送短信的时候,如果不单独写一个线程类发送短信的话,系统会提示,可能产生死锁。解决此问题只需要单独写个线程类来发送即可,示例如下:
public class sendThread extends Thread { private String phone; private String content; public sendThread(String phone, String content) { this.phone = phone; this.content = content; } public void run() { try { String addr = "sms://" + phone; //System.out.println("发送地址为:" + addr); MessageConnection conn = (MessageConnection) Connector.open(addr); TextMessage msg = (TextMessage) conn.newMessage(MessageConnection. TEXT_MESSAGE); msg.setPayloadText(content); conn.send(msg); conn.close(); } catch (Exception e) { //System.out.println("Error in sending"); e.printStackTrace(); } } }