Download - Scmad Chapter10
By Marcel Caraciolo
http://mobideia.blogspot.com
Chapter 10– Wireless Messaging API
SCMAD Certification 45mm
61m
m
Agenda•WMA•Wireless Messaging API•Messaging Connector•Message Types•Classes•Permissions
WM WMA – Wireless Messaging API
•API for sending and receiving mobile phone messages (SMS, MMS, etc.)•Defined over GCF•Similar to datagram, but uses different API:
javax.microedition.messaging•Messages may be:•Text Message (sends String though SMS messages)•Binary Message (sends byte arrays over SMS messages)•MultipartMessage (MMS, only available at WMA 2.0)
•Message infrastructures usually are “store-and-forward” : if the destination device is not available when the message is sent, it may be delivered later.
WM WMA – Wireless Messaging API
•Messages are composed of:•An address (may be destination or origin address, according to the context)•A TimeStamp from when it was sent•“Payload” itself
•It’s a protocol-independent API, but has the same QOS of the protocol•Sending a message is usually billed, so this must be considered when designing the application•Like any network operation, messages must be sent and received on a separate thread
M Message Connection
•Extends Connection: Although very similar to datagrams , SMS messages are not considered datagrams•Created using Connector.open(“sms://[phoneNumber]:[:port]”)•If no port is informed, the message will be sent to the device’s inbox. If it’s informed, it’s sent to an application waiting on that port. It’s impossible to access or intercept messages sent to the inbox•Trying to open streams (e.g. Connector.openOutputStream()) with WMA protocols throws an exception since these protocols are not stream-oriented
M Message Connection
•There are “client” and “server” connections:•Client : “sms: //12345678:1234” Can only send messages to this number•Server: “sms://:1234” Can send messages to any number and also receive messages. Server connections must always inform a port number.
M Message Connection
•MessageConnection object works as:•Factory Method for creating messages (newMessage(type),
newMessage(type, address))•Sending messages•Receiving messages•Calculating how many segments a message will consume (a message may be larger than the maximum size supported by the protocol. In this case several messages are sent and re-organized by the receiver)•MessageListener may be registered to notify message arrivals
M Message Types
•SMS (Short message service):•Supports 140 bytes payload. The number of character per message depends on the encoding:• 7 Bits: 160 characters• 8 Bits: 140 characters•16 Bits: 70 characters
•WMA allows sending messages bigger than allowed by the protocol (sending several messages (segments)). Devices must support messages with at least 3 segments (420 bytes).
M Message Types
•CBS(Cell broadcast service):•Messages may only be received (broadcast). You cannot open CBS connections in “client” mode or send CBS messages
M WMA: Class Diagram
WMA: Permissions
•javax.microedition.io.Connector.sms•javax.microedition.io.Connector.cbs•javax.microedition.io.Connector.mms•javax.wireless.messaging.sms.send•javax.wireless.messaging.sms.receive•javax.wireless.messaging.cbs.receive
Example Codes
• Some examples and MIDlets samples are available for reference and studying at this link:•http://www.dsc.upe.br/~mpc/chapter10.rar
•The source codes include:•SMSMIDlet
Future Work
• Next Chapter:
• MIDP - Deployment• MIDlet Suites• JAD Descriptor• OTA Provisioning
•MIDP – Push Registry•Push Registry•Static Registry•PushRegistry
References
• ALVES F. Eduardo. SCMAD Study Guide, 27/04/2008.
• JAKL Andreas, Java Platform, Micro Edition Part 01 slides, 12/2007.
• Sun Certification Mobile Application Developer Website: [http://www.sun.com/training/certification/java/scmad.xml].