Developing a Newsreader in Java
- Architecture of the System
- How to Read the XML News File
- The Application
Accessing news is one of the most important uses of mobile applications. News headlines and quick news give us a lot of important information, and we can (almost) always find another source for information when something interesting or important happens. In this article, we'll design and implement a newsreader with mobile Java to run in mobile phones that support MIDP 1.0.
Architecture of the System
The network architecture of the application (see Figure 1) is very simple; it consists of the mobile client and a website offering news in XML format. The news provider is a free news service provider called XML News.net, which offers news related to XML. There are numerous other news services around the globe that has their news or headlines in XML format. So it is easy to modify this application to suit your own provider's news feed.
Figure 1 The network architecture of the application.
The first screen of the application displays a list of headlines. These headlines can be long texts, and the user can see only the few first words in the list. When the user chooses the headline, another display shows the whole headline.
The class diagram of the application is shown in Figure 2. The MIDP classes are in italic, the new classes are in bold, and the third-party XML parser is both italic and underlined. The class diagram shows the associations between classes, and it also shows which of the MIDP's classes we have used.
Figure 2 The Class diagram of the application.
The NewsReaderMIDlet is the main class of the application. It creates the other classes and acts as command listener for all the actions and command. For the http connection, we used a wrapper class, which takes care of the details in the http connection and also fills the menu. The details are shown with the HeadLineDetail class, which is inherited from Form.