import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.io.Connector; import javax.wireless.messaging.*; public class smsClass extends MIDlet implements CommandListener { private TextBox textF; private TextField numF; private Display display; private Command next; private Command send; private String getnum=""; private String getmes=""; public void startApp() { display=Display.getDisplay(this); next=new Command("Next",Command.OK,1); textF=new TextBox("Введите текст sms","",100,TextField.ANY); textF.addCommand(next); display.setCurrent(textF); textF.setCommandListener(this); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void numberField(){ Form form=new Form("Введите номер телефона"); numF=new TextField("Numer","",15,TextField.NUMERIC); send=new Command("Send SMS",Command.OK,1); form.append(numF); form.setCommandListener(this); form.addCommand(send); display.setCurrent(form); } public void setSMS(){ try{ String addr="sms://+"+getnum; MessageConnection conn=(MessageConnection)Connector.open(addr); TextMessage msg=(TextMessage)conn.newMessage(MessageConnection.TEXT_MESSAGE); msg.setPayloadText(getmes); conn.send(msg); } catch(Exception exception){} } public void commandAction(Command c,Displayable displayable){ if(c==next){ numberField(); } if(c==send){ getnum=numF.getString(); getmes=textF.getString(); setSMS(); } } }