Write an application that listens for data from a server-side push application.
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.
In the IDE, open the http_push.jdw workspace
Open the FilePush.java source file.
Ask your instructor about additional setup requirements.
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.
In the ListeningThread inner class, add a stop method to close the network connection.
In the FilePush constructor, add code to start the listening thread.
In the onExit method, add code to stop the listening thread.
In the updateText method, add code to display the text that has been received.
Start the Mobile Data Service (MDS) simulator.
Check Your Work
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