Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Listening for pushed data

by Retired on ‎02-12-2010 02:50 PM - edited on ‎11-22-2010 07:24 PM by (5,049 Views)

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. Open http_push_1.zip
  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

 

Check http_push_2.zip

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
Contributors
Users Online
Currently online: 28 members 2,459 guests
Please welcome our newest community members: