Categories: Java | Java ME | Code Examples | Messaging | SMS | WMA 1.0 (JSR-120)
This page was last modified 02:11, 4 July 2008.
Message handling in Java Platfrom, Micro Edition (Java ME)
From Forum Nokia Wiki
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(); } }
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 7210 Newbie | isaacinsoll | Mobile Java General | 2 | 2002-12-30 09:41 |
| create a forward lock on the fly with java | twoandtwo | Digital Rights Management & Content Downloading | 6 | 2006-10-30 12:50 |
| AT commands in Java | nuaimat | General Messaging | 3 | 2006-03-21 07:44 |
| Connect to agent error | glaubertadeu | Mobile Java Tools & SDKs | 4 | 2008-05-31 22:04 |
| Which version of Java? | Poldie | Mobile Java General | 7 | 2006-03-14 10:52 |
