">Slide show

MIDP - Mobile Information Device Profile - version 1.0


Portability


Networking with MIDP - Connector class


Connection hierachy


Connection subclasses


HttpConnection


HttpConnection example


    void getFromHttpConnection(String url) throws IOException {
         HttpConnection conn = null;
         InputStream is = null;
         try {
             conn = (HttpConnection )Connector.open(url);
 
             // Getting the InputStream will open the connection
             // and read the HTTP headers. They are stored until
             // requested.
             is = conn.openInputStream();
 
             // Get the ContentType
             String type = conn.getType();
 
             // Get the length and process the data
             int len = (int) conn.getLength();
             if (len > 0) {
                 byte[] data = new byte[len];
                 int actual = is.read(data);
                 ...
             } else {
                 int ch;
                 while ((ch = is.read()) != -1) {
                     ...
                 }
             }
         } finally {
             if (is != null)
                 is.close();
             if (conn != null)
                 conn.close();
         }
     }


Two-way communication using HttpConnection


MIDlet class


Application structure


Application shell


Compiling and running

Assume you have unpacked the J2ME wireless toolkit into a directory such as WTK=/usr/local/personaljava/WTK2.0


Lists


List types


Command


CommandListener


Command listener example


TextBox


TextBox example


Form


Form example


Canvas


Graphics


Canvas drawing example


Canvas Listeners


Keycodes


Game actions


Canvas key example


Persistent store


Binary data


Binary data example


Creating/opening RecordStore


Adding records


Record enumerator


Record store example


What's missing?


References



Jan Newmarch <jan@newmarch.name>
Last modified: Fri Dec 3 20:11:08 EST 2004