The Wireless Messaging API (WMA) provides a common interface you can use to enable an application based on the Mobile Information Device Profile (MIDP) to send and receive short text and binary messages, as well as multimedia messages. These messages typically are part of store-and-forward messaging systems such as the Short Messaging Service (SMS) and the Multimedia Messaging Service (MMS) that guarantee delivery of messages.
All WMA-specific interfaces and classes are contained in a single package, javax.wireless.messaging, which defines all the APIs required for sending and receiving wireless text, binary, and multi-part messages.
BinaryMessage
An interface representing a binary message.
Message
This is the base interface for derived interfaces that represent various types of messages.
MessageConnection
The MessageConnection interface defines the basic functionality for sending and receiving messages.
MessageListener
The MessageListener interface provides a mechanism for the application to be notified of incoming messages.
TextMessage
An interface representing a text message.
Sending SMS Code Snippet:
MessageConnection con = (MessageConnection)Connector.open(address); TextMessage txtmsg =(TextMessage) con.newMessage(MessageConnection.TEXT_MESSAGE); txtmsg.setPayloadText(smsmsg); txtmsg.setAddress(address); con.send(txtmsg);
Receiving SMS Using Push Registry:
// This is registered to the port number 1111 // Should implement MessageListener. try{ PushRegistry.registerConnection("sms://:1111",this.getClass().getName(),"*"); }catch(Exception e){} String[] connList; connList = PushRegistry.listConnections(true); if((connList == null) || (connList.length == 0)) { destroyApp(true); notifyDestroyed(); } else { try{ msgconn = (MessageConnection)Connector.open("sms://:1111"); msgconn.setMessageListener(this); } catch(IOException e){ e.printStackTrace();} public void notifyIncomingMessage(MessageConnection conn) { try{ TextMessage txtmsg = (TextMessage)msgconn.receive(); }catch(Exception e){System.out.println(e);} String newmsg = txtmsg.getPayloadText(); String msgaddr = txtmsg.getAddress(); } }
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| illegal argument exception | jwidd | Mobile Java General | 4 | 2007-10-01 21:43 |
| Incoming SMS Sender Name | devdattac | Mobile Java Networking & Messaging & Security | 6 | 2008-09-29 15:41 |
| Messages sent via WMA cannot be viewed | jords1 | Mobile Java Networking & Messaging & Security | 6 | 2008-10-28 23:10 |
| is there a File class equivalent in J2ME? | rj_cybersilver | Mobile Java General | 44 | 2007-08-18 16:51 |
| 3410 NOKIA uses WMA? | alinesimon | Mobile Java General | 1 | 2004-07-25 09:25 |