example.sms
Class SMSReceive

java.lang.Object
  extended by javax.microedition.midlet.MIDlet
      extended by example.sms.SMSReceive
All Implemented Interfaces:
java.lang.Runnable, javax.microedition.lcdui.CommandListener, javax.wireless.messaging.MessageListener

public class SMSReceive
extends javax.microedition.midlet.MIDlet
implements javax.microedition.lcdui.CommandListener, java.lang.Runnable, javax.wireless.messaging.MessageListener

An example MIDlet displays text from an SMS MessageConnection


Field Summary
(package private)  java.lang.String[] connections
          Connections detected at start up.
(package private)  javax.microedition.lcdui.Alert content
          user interface text box for the contents of the fetched URL.
(package private)  javax.microedition.lcdui.Display display
          current display.
(package private)  boolean done
          Flag to signal end of processing.
(package private)  javax.microedition.lcdui.Command exitCommand
          user interface command for indicating Exit request.
(package private)  javax.wireless.messaging.Message msg
          Current message read from the network.
(package private)  javax.microedition.lcdui.Command replyCommand
          user interface command for indicating Reply request
(package private)  javax.microedition.lcdui.Displayable resumeScreen
          The screen to display when we return from being paused
(package private)  SMSSender sender
          Prompts for and sends the text reply
(package private)  java.lang.String senderAddress
          Address of the message's sender
(package private)  javax.microedition.lcdui.Alert sendingMessageAlert
          Alert that is displayed when replying
(package private)  javax.wireless.messaging.MessageConnection smsconn
          SMS message connection for inbound text messages.
(package private)  java.lang.String smsPort
          The port on which we listen for SMS messages
(package private)  java.lang.Thread thread
          instance of a thread for asynchronous networking and user interface.
 
Constructor Summary
SMSReceive()
          Initialize the MIDlet with the current display object and graphical components.
 
Method Summary
 void commandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable s)
          Respond to commands, including exit
 void destroyApp(boolean unconditional)
          Destroy must cleanup everything.
 void notifyIncomingMessage(javax.wireless.messaging.MessageConnection conn)
          Notification that a message arrived.
 void pauseApp()
          Pause signals the thread to stop by clearing the thread field.
 void run()
          Message reading thread.
 void startApp()
          Start creates the thread to do the MessageConnection receive text.
 
Methods inherited from class javax.microedition.midlet.MIDlet
checkPermission, getAppProperty, notifyDestroyed, notifyPaused, platformRequest, resumeRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

exitCommand

javax.microedition.lcdui.Command exitCommand
user interface command for indicating Exit request.


replyCommand

javax.microedition.lcdui.Command replyCommand
user interface command for indicating Reply request


content

javax.microedition.lcdui.Alert content
user interface text box for the contents of the fetched URL.


display

javax.microedition.lcdui.Display display
current display.


thread

java.lang.Thread thread
instance of a thread for asynchronous networking and user interface.


connections

java.lang.String[] connections
Connections detected at start up.


done

boolean done
Flag to signal end of processing.


smsPort

java.lang.String smsPort
The port on which we listen for SMS messages


smsconn

javax.wireless.messaging.MessageConnection smsconn
SMS message connection for inbound text messages.


msg

javax.wireless.messaging.Message msg
Current message read from the network.


senderAddress

java.lang.String senderAddress
Address of the message's sender


sendingMessageAlert

javax.microedition.lcdui.Alert sendingMessageAlert
Alert that is displayed when replying


sender

SMSSender sender
Prompts for and sends the text reply


resumeScreen

javax.microedition.lcdui.Displayable resumeScreen
The screen to display when we return from being paused

Constructor Detail

SMSReceive

public SMSReceive()
Initialize the MIDlet with the current display object and graphical components.

Method Detail

startApp

public void startApp()
Start creates the thread to do the MessageConnection receive text. It should return immediately to keep the dispatcher from hanging.

Specified by:
startApp in class javax.microedition.midlet.MIDlet

notifyIncomingMessage

public void notifyIncomingMessage(javax.wireless.messaging.MessageConnection conn)
Notification that a message arrived.

Specified by:
notifyIncomingMessage in interface javax.wireless.messaging.MessageListener
Parameters:
conn - the connection with messages available

run

public void run()
Message reading thread.

Specified by:
run in interface java.lang.Runnable

pauseApp

public void pauseApp()
Pause signals the thread to stop by clearing the thread field. If stopped before done with the iterations it will be restarted from scratch later.

Specified by:
pauseApp in class javax.microedition.midlet.MIDlet

destroyApp

public void destroyApp(boolean unconditional)
Destroy must cleanup everything. The thread is signaled to stop and no result is produced.

Specified by:
destroyApp in class javax.microedition.midlet.MIDlet
Parameters:
unconditional - true if a forced shutdown was requested

commandAction

public void commandAction(javax.microedition.lcdui.Command c,
                          javax.microedition.lcdui.Displayable s)
Respond to commands, including exit

Specified by:
commandAction in interface javax.microedition.lcdui.CommandListener
Parameters:
c - user interface command requested
s - screen object initiating the request