example.http
Class HttpTest

java.lang.Object
  extended by javax.microedition.midlet.MIDlet
      extended by example.http.HttpTest
All Implemented Interfaces:
java.lang.Runnable, javax.microedition.lcdui.CommandListener

public class HttpTest
extends javax.microedition.midlet.MIDlet
implements javax.microedition.lcdui.CommandListener, java.lang.Runnable

An example MIDlet to fetch a page using an HttpConnection. Refer to the startApp, pauseApp, and destroyApp methods so see how it handles each requested transition. Note: if you run this inside POSE using a multi-homed PC (with more than one network connections), POSE doesn't know how to resolve host names not connected to the first network card. To solve this, add a line like this in your c:/WINNT/system32/drivers/etc/hosts file: 204.71.202.160 www.yahoo.com


Constructor Summary
HttpTest()
          Initialize the MIDlet with a handle to the current display
 
Method Summary
(package private)  void addScreen()
          Add another screen.
(package private)  void chooseScreen()
          Pick a screen.
 void commandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable s)
          Respond to commands, including exit
(package private) static void DEBUG(java.lang.String s)
          Debug output routine.
 void destroyApp(boolean unconditional)
          Destroy must cleanup everything.
(package private)  void mainScreen()
          Display the main screen.
 void pauseApp()
          Pause signals the thread to stop by clearing the thread field.
 void run()
          Perform the current command set by the method commandAction.
(package private)  void setCommands(javax.microedition.lcdui.Displayable d, boolean islist)
          Set the funtion to perform based on commands selected.
 void startApp()
          Start creates the thread to do the timing.
 
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
 

Constructor Detail

HttpTest

public HttpTest()
Initialize the MIDlet with a handle to the current display

Method Detail

DEBUG

static final void DEBUG(java.lang.String s)
Debug output routine.

Parameters:
s - string to be printed.

startApp

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

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

mainScreen

void mainScreen()
Display the main screen.


chooseScreen

void chooseScreen()
Pick a screen.


addScreen

void addScreen()
Add another screen.


setCommands

void setCommands(javax.microedition.lcdui.Displayable d,
                 boolean islist)
Set the funtion to perform based on commands selected.

Parameters:
d - Displayable object
islist - flag to indicate list processing

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 - Flag to indicate that forced shutdown is 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 - command to perform
s - Screen displayable object

run

public void run()
Perform the current command set by the method commandAction.

Specified by:
run in interface java.lang.Runnable