|
This page provides links to a variety of code samples that use the MIDP APIs.
M-Commerce
Client-Side Download |
Server-Side Download
The Mobile Resource Management System" or "m-RMS." sample
application is a resource management and tracking system
for Mobile Information devices such as PDAs and Phones.
m-RMS uses J2ME (CLDC + MIDP) and XML technology and
communicates wirelessly over TCP/IP to a backend
J2EE framework.
Be sure to take a look at the
Readme
file for the application.
Event Handling
EventEx1.java
This example creates a list of items (Item1 to Item4) and calls the prepare method whenever an item is selected. The testItem# methods, where # is a number between 1 and 4, call the prepare method and set the name of the menu. Example described in MIDP Event Handling
EventEx2.java
In this example a DateField object is created and added to a form. When you click on the date, you can change it by navigating through the calendar. When the date is changed, a message appears. Example described in MIDP Event Handling
EventEx3.java
In this example, the Canvas class is subclassed to use an anonymous inner class, an implementation is provided for the keyPressed and keyReleased methods, and an empty implementation is provided for the paint method. When a key is pressed or released, the application prints the value of that key. Example described in MIDP Event Handling
Network Connections
FirstExample.java
This example uses the StreamConnection class to read the contents
of a file referenced by a URL. Example described in MIDP
Network Programming Using HTTP and the Connection Framework.
SecondExample.java
This example uses the HttpConnection class to fetch a page. Example
described in MIDP Network Programming Using HTTP
and the Connection Framework.
ThirdExample.java
This example invokes a CGI script from the HTTP server side, and the results
are captured and displayed on the handheld device screen. Example described
in MIDP Network Programming Using HTTP and
the Connection Framework.
Persistent Storage
Stock.java
This class parses a string obtained from the Yahoo Quote Server or the record store
into fields (such as name of stock or price). In this MIDlet, the fields retrieved
are the name of the stock, the time, and the price. Example described in
MIDP Database Programming using RMS
StockDB.java
This class provides methods that open a new record store, add a new record to the
record store, close the record store, and enumerate through the records. Example
described in MIDP Database Programming using
RMS
QuotesMIDlet.java
This example creates the List Stocks, Add New Stock, Back, Save, and Exit commands,
handles command events, connects to the YAHOO Quote Server to retrieve quotes, and
invokes methods from Stock and StockDB to parse quotes
and add new stocks to the record store. Example described in MIDP Database Programming using RMS
Getting Started
FirstMIDlet.java
This example displays a simple text message and a few commands. Example described in Wireless Application Programming: MIDP Programing and Packaging Basics
HelloMIDlet.java
This example adds a ticker and icons to the HelloMIDlet program that comes with the MIDP installation. A ticker is an advertisement that runs across the top of the screen. Example described in Wireless Application Programming: MIDP Programing and Packaging Basics
Servlets
FirstMidletServlet.java
In this example, FirstMidletServlet is invoked with the GET
method and the response is received and displayed on the handset. No input is sent to
the servlet. When invoked the servlet sends the Servlet Invoked string and the
date back to the client. Example described in MIDP Inter-Communication with CGI and Servlets.
HelloServlet.java
This example sends the Servlet Invoked! message and date to the
client. Example described in MIDP
Inter-Communication with CGI and Servlets.
PostMidlet.java
This example invokes a CGI script from a MIDlet using the POST
method. The input is sent to the script in a message. Example described in MIDP Inter-Communication with CGI and Servlets.
RequestServlet.java
This example retrieves the POST request from the buffer
and sends the input values back to the client. Example described in
MIDP Inter-Communication
with CGI and Servlets.
SecondMidletServlet.java
This exampleprompts the user to enter a first name, and when the
user presses the key that corresponds to the Submit command, the
RequestServlet is invoked. RequestServlet
retrieves the input values of the request from the buffer and returns
it back to the client to show that the servlet received the POST
request. Example described in MIDP
Inter-Communication with CGI and Servlets.
User Interface
GuiTests.java
This example demonstrates how to create various GUI components. The MIDlet for this example allows you to test lists, forms, choices, gauges, text fields, text boxes, for example. Example described in
MIDP GUI Programming: Programming the Phone Interface.
|