📄 pushregistrymidlet.java
字号:
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
import javax.wireless.messaging.*;
import java.io.IOException;
import javax.microedition.io.Connector;
public class PushRegistryMidlet extends MIDlet implements CommandListener, Runnable, MessageListener {
private String smsPort;
private MessageConnection smsconn ;
private Thread mcT;
private TextMessage msg;
private Form messageForm;
private Display dis;
public PushRegistryMidlet() {
super();
messageForm = new Form("the information of pushRegistry!");
messageForm.append("First Test!!!!!");
dis = Display.getDisplay(this);
}
protected void startApp() throws MIDletStateChangeException {
smsPort = this.getAppProperty("SMS-Port");
String smsConnection = "sms://:" + smsPort;
if(smsconn == null)
{
try{
smsconn = (MessageConnection) Connector.open(smsConnection);
smsconn.setMessageListener(this);
}catch(IOException e){}
}
dis.setCurrent(messageForm);
}
protected void pauseApp() {
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
public void commandAction(Command c, Displayable d)
{
}
public void notifyIncomingMessage(MessageConnection mc)
{
if(mcT == null)
{
mcT = new Thread(this);
mcT.start();
}
}
public void run()
{
try{
msg = (TextMessage)smsconn.receive();
if(msg != null && msg instanceof TextMessage)
{
messageForm.append(((TextMessage)msg).getPayloadText());
}
}catch(IOException e){ e.printStackTrace();}
dis.setCurrent(messageForm);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -