Java Reference
In-Depth Information
The major differences are as follows:
The MIDlet is called MMSMIDlet and the sender class is called MMSSender .
The MIDlet uses the nonblocking, event-driven notification mechanism to receive
messages.
Instead of just the text “red” or “blue” in an SMS message, the entire image to be
displayed is sent as a MessagePart in a MultipartMessage .
First, Listing 11-3 shows the code for the MMSMIDlet .
Listing 11-3. The MMSMIDlet for Sending and Receiving MMS
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.wireless.messaging.*;
import java.io.IOException;
public class MMSMIDlet
extends MIDlet
implements CommandListener, MessageListener,Runnable {
private MMSSender mSender = null;
private Thread mReceiver = null;
private Command mExitCommand = new Command("Exit", Command.EXIT, 2);
private Command mRedCommand = new Command("Send Red", Command.SCREEN, 1);
private Command mBlueCommand = new Command("Send Blue", Command.SCREEN, 1);
protected static final String RED_IMAGE = "/red.png";
protected static final String BLUE_IMAGE = "/blue.png";
protected static final String DEFAULT_IMAGE = "/wait.png";
private Display mDisplay = null;
protected ImageItem mColorSquare = null;
protected Image mInitialImage = null;
private String mAppID = "MMSMIDlet";
private TextField mNumberEntry= null;
private Form mForm = null;
private Integer mMonitor = new Integer(0);
public MMSMIDlet() {
mSender = MMSSender.getInstance();
}
Search WWH ::




Custom Search