Messaging in the mobile world can take several forms: SMS (text), Picture Messaging (text and graphics), smart messaging (short messages holding content such as ringtones and notifications), and MMS (digital image input) can be sent with the mobile device. Note that not all these are available in all devices.
The Wireless Messaging API (JSR-205) specification allows you to compose, send, and receive SMS, MMS, and CBS messages through JavaTM applications (MIDlets).
The Wireless Messaging API (WM API) is based on the Generic Connection Framework (GCF). The GCF is defined in the javax.microedition.io
package
of the Connected Limited Device Configuration (CLDC) 1.0 specification. The
package defines an extensible framework for connections and supports input/output
and networking functionality in Java Platform Micro Edition profiles.
Representation of a message
A message can be thought of as having an address part and a data part.
A message is represented by a class that implements the interface defined
for messages in the WM API 2.0. This interface provides methods that are common
for all messages. In the javax.wireless.messaging
package,
the base interface that is implemented by all messages is named Message
.
It provides methods for addresses and timestamps.
For the data part of the message, the WM API 2.0 is designed to handle
text, binary and multipart messages. These are represented by three subinterfaces
of Message
: TextMessage
, BinaryMessage
and MultipartMessage
.
These subinterfaces provide ways to manipulate the payload of the message
as Strings
, byte arrays and message parts, respectively.
Other subinterfaces of Message
can be defined for
message payloads which are neither pure text nor pure binary. It is also possible
to create further subinterfaces of TextMessage
, BinaryMessage
and MultipartMessage
for
possible protocol-specific features.
Sending and receiving messages
As defined by the Generic Connection Framework, the message sending
and receiving functionality is implemented by a Connection
interface,
in WM API 2.0's case, MessageConnection
. To make a connection,
the application obtains an object implementing the MessageConnection
from
the Connector
class by providing a URL connection string
that identifies the address.
For more information about the sending and receiving of messages, see the Wireless Messaging API (JSR-205) specification.
Permissions for S60 and Series 40 MIDP 2.0 Platforms
When the WM API 2.0 interfaces are deployed on a S60 and Series 40 MIDP 2.0 device, permissions must be granted to open a connection and to send and receive messages. Separate permissions are provided for the SMS and CBS protocols.
To open a connection, a MIDlet suite must have the appropriate permission
to access the MessageConnection
implementation. If the
permission is not granted, then Connector.open
must throw
a SecurityException
. To send and receive messages, the
MIDlet suite can restrict certain types of messages or connection addresses.
If the application attempts to send or receive either a restricted type of
message or a message with a restricted connection address, then a SecurityException
must
be thrown.
For more information about the permissions in WM API 2.0, see Appendix E of Wireless Messaging API (JSR-205) specification.
The following developer's guide is available on messaging in this section.
Describes using the Wireless Messaging API and provides an example MIDlet which uses the device camera to take a picture that can be then sent with a text note as an MMS message to a given number.