|
 |
 |
Exercise
Write an application that retrieves a text file over the network using HTTP.
Objectives
- Discover how to use the Mobile Data Service (MDS) simulator.
- Discover how to open an HTTP connection
- Discover how to retrieve data over an HTTP connection and display it.
Setup
- Download the file
- In the IDE, open the http_request.jdw workspace
- Open the HTTPFetch.java source file.
Tasks
- Change the SAMPLE_PAGE constant to define the test page to retrieve. Ask your instructor for this information.
- Create a ConnectionThread object.
- In the ConnectionThread inner class, add code to open the connection and retrieve the data.
- In the HTTPFetch constructor, start the connection thread and invoke the fetchPage method.
- Add code to the fetchPage method to invoke ConnectionThread.fetch().
- Add code to the updateContent method to display the text that has been retrieved on the screen.
- Add code to the onExit method to stop the connection thread.
- Create the application constructor.
- Start the Mobile Data Service (MDS) simulator.
- Build and run the application.
Check Your Work
Download the completed code
Review
In this exercise, you discovered the following things:
- how to use the MDS simulator to test network connectivity
- how to open an HTTP connection and retrieve data
- how to display retrieved data on the user interface
Additional Labs
Go to the first exercise in “Developing User Interfaces for BlackBerry”, Introduction to User Interface managers
Back to the Developer Lab Main Menu
|
|
|
|