BlackBerry
Skip Top Navigation
Developers Partners
North America [change region] Products Solutions Purchasing Support
Developers


Listening for Pushed Data

Exercise

Write an application that listens for data from a server-side push application.

Objectives

  • Discover how to create a separate listener thread.
  • Discover how to receive and display pushed data.
  • Discover how to use the Mobile Data Service (MDS) simulator.

Setup

  1. Download the file
  2. In the IDE, open the http_push.jdw workspace
  3. Open the FilePush.java source file.
  4. Ask your instructor about additional setup requirements.

Tasks

  1. In the ListeningThread inner class, add code to open a server-side socket connection and an input stream, receive pushed data, and display data to the user. TIP: Most code needs to be added in the run method.
  2. In the ListeningThread inner class, add a stop method to close the network connection.
  3. In the FilePush constructor, add code to start the listening thread.
  4. In the onExit method, add code to stop the listening thread.
  5. In the updateText method, add code to display the text that has been received.
  6. Start the Mobile Data Service (MDS) simulator.

Check Your Work

Download the completed code

Review

In this exercise, you discovered the following things:

  • how to create separate threads for background tasks
  • how to open a connection to listen for pushed data
  • how to display pushed data on the UI
  • how to use the Mobile Data Service simulator for testing


Additional Labs

Go to the next exercise in "Working with Multiple Processes and Threads", Communicating with other applications

Back to the Developer Lab Main Menu

 
Other Resources
 
     
 Home | Products | Solutions | Purchasing | Support | Developers | Worldwide | News | About Us | Contact Us | Site Map
 Legal | Copyright © 2008 Research In Motion Limited, unless otherwise noted.