⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pushregistrymidlet.java

📁 这是一个推机制的java 程序
💻 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 + -