The MMS MIDlet presented in this document uses the Mobile Media API
(MMAPI) Player
interface to capture an image using the
device camera. The captured image and a written text note are then bundled
into an MMS message, that is, the sent messages contain only two parts: one
bitmap image (image/jpeg
) and one text field (text/plain
).
The MIDlet's user interface has three screens: one for acquiring an
image, one for composing the message to be sent, and one for presenting a
received message. The message composition form contains the snapshot image
and user-editable fields for the destination number and the text message.
When the user presses "Send," the sendMessage
method
of the main class is called and the message is sent in a new thread. Both
the receiving and the sending end use the same application ID in their
connections to be able to explicitly communicate with each other.
On the receiving end, the application listens for incoming messages and displays them upon their arrival. Note that the application offers no way to manage multiple incoming messages. Therefore, if several messages are received in a row, only the last one is displayed while the others are lost.
The MIDlet is composed of the main MMSMIDlet
class
and the three screens, as shown in the figure below.
Note: The MIDlet does not register itself to be woken up when a message arrives.
This implies that on the receiving end, the user must manually start the MIDlet
to process an incoming message. Another option that is useful for testing
is to run the MIDlet and send a message to its own number. In MIDP 2.0, PushRegistry
could
be used to automatically start the MIDlet when a message is received. However,
such a feature is not implemented in this example.