Java Reference
In-Depth Information
Listing 14-6. The SMSMidlet Class
package com.apress.rischpater.smsmidlet;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.wireless.messaging.*;
import java.io.IOException;
public class SMSMIDlet
extends MIDlet
implements CommandListener, MessageListener, Runnable {
private SMSSender sender = null;
private Command exitCommand = new Command("Exit", Command.EXIT, 2);
private Command sendCommand = new Command("Send", Command.SCREEN, 1);
private final String port = "1234";
private TextField numberEntry= null;
private TextField msgEntry = null;
private Form form = null;
private String senderAddress = null;
private boolean endNow = false;
private MessageConnection c = null;
String msgReceived = null;
public SMSMIDlet() {
sender = SMSSender.getInstance();
}
public void commandAction(javax.microedition.lcdui.Command c,
javax.microedition.lcdui.Displayable d) {
if (c == exitCommand) {
if (!sender.isSending()) {
destroyApp(true);
notifyDestroyed();
}
} else if (c == sendCommand) {
String dest = numberEntry.getString();
String msg = msgEntry.getString();
if (dest.length() > 0)
sender.sendMsg(dest, port, msg);
}
}
 
Search WWH ::




Custom Search