×
Namespaces

Variants
Actions
Revision as of 15:50, 16 July 2009 by Mvijay060 (Talk | contribs)

WMA 1.0 (JSR-120)

From Nokia Developer Wiki
Jump to: navigation, search

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.

Interface Summary

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);.l/
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();
}
}
78 page views in the last 30 days.
×