×
Namespaces

Variants
Actions

WMA 1.0 (JSR-120)

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: arunjyothiskp (28 Nov 2007)
Last edited: lpvalente (22 Feb 2014)

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();
}
}
This page was last modified on 22 February 2014, at 21:17.
77 page views in the last 30 days.
×