×
Namespaces

Variants
Actions
Revision as of 13:20, 15 November 2013 by lpvalente (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

SMS handling in Java ME

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: arunjyothiskp (21 Nov 2007)
Last edited: lpvalente (15 Nov 2013)

Introduction

Sending and receiving messages are carried out by the messaging API, JSR 120. The messaging API is based on the Generic Connection Framework (GCF), which is defined in the Connected Limited Device Configuration (CLDC) 1.0 specification. The package javax.microedition.io defines the framework and supports input/output and networking functionality in J2ME profiles. It provides a coherent way to access and organize data in a resource-constrained environment.

Code Sample 1 – A simplified version of the message handling classes

class MessageListenerImpl implements MessageListener
{
public void notifyIncomingMessage(MessageConnection mCon)
{
messageReader.handleMessage();
}
}
 
class WirelessMessageReader implements Runnable
{
 
private boolean readMessages = true;
 
private int pendingMessages;
 
private MessageConnection msgConn = null;
 
 
public void run()
{
while(readMessages)
{
synchronized(this)
{
if(pendingMessages == 0)
{
try
{
wait();
}
catch(InterruptedException ie) {}
}
pendingMessages--;
}
Message message = null;
try
{
Message message = msgConn.receive();
/* parse payload */
}
catch(IOException ioe) {}
}
}
 
synchronized void handleMessage()
{
pendingMessages++;
notify();
}
}
This page was last modified on 15 November 2013, at 13:20.
46 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×