import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.io.Connector; import javax.wireless.messaging.*; import java.io.*; import javax.microedition.io.PushRegistry; public class ui extends MIDlet implements CommandListener,Runnable,MessageListener { public Display display; public Form userint; public Command exit; public Command send; public TextField username; public TextField pin; public String un; public String pn; public TextMessage mymsg; public Alert disalert; //public String dest="123456"; //public String dest_port; //public String dest_add="sms://" +dest+":"+dest_port; public MessageConnection mycon=null; public ui() { //dest_port=getAppProperty("SMS-Port"); display=Display.getDisplay(this); send=new Command("SEND",Command.SCREEN,1); exit=new Command("EXIT",Command.EXIT,0); username=new TextField("USERNAME:","",20,TextField.ANY); pin=new TextField("PIN:","",10,TextField.PASSWORD); userint=new Form("USERINTERFACE"); userint.append(username); userint.append(pin); userint.addCommand(send); userint.addCommand(exit); userint.setCommandListener(this); } public void startApp() { display.setCurrent(userint); } public void pauseApp() { } public void destroyApp(boolean abc) { notifyDestroyed(); } public void commandAction(Command c,Displayable d) { if(c==send) { un=username.getString(); pn=pin.getString(); //sendmsg(); new Thread(this).start(); //destroyApp(true); //notifyDestroyed(); disalert=new Alert("DATA SENT","WAIT FOR A MESSAGE ",null,AlertType.INFO); disalert.setTimeout(50000); disalert.addCommand(exit); disalert.setCommandListener(this); display.setCurrent(disalert); } if(c==exit) { destroyApp(true); } } public void run() { try { mycon=(MessageConnection)Connector.open(/*dest_add*/"sms://:6000"); mymsg=(TextMessage)mycon.newMessage(MessageConnection.TEXT_MESSAGE); mymsg.setPayloadText(un+pn); mycon.send(mymsg); mycon.setMessageListener(this); //mycon.close(); /*public void notifyIncomingMessage(MessageConnection mycon) { Message msg = mycon.receive(); //do whatever you want with the message if(msg instanceof TextMessage) { //TextMessage tmsg = (TextMessage) msg; System.out.println(mymsg.getPayloadText()); } }*/ } catch(Exception ex1) { } // Time to receive one. //get reference to MessageConnection object } public void notifyIncomingMessage(MessageConnection mycon) { try { Message msg = mycon.receive(); //do whatever you want with the message if(msg instanceof TextMessage) { //TextMessage tmsg = (TextMessage) msg; System.out.println(mymsg.getPayloadText()); } } catch(Exception e) { } } } //please help me with d port number and address..