Designing Network Applications

Although mobile devices have come a long way in terms of computing speed and data storage, servers can still provide valuable processing power for backing up data or for providing ease of data portability between devices or access to portions of larger datasets that can't be retained on the local device. Luckily, mobile devices have also come a long way in terms of their ability to connect to networks and the Internet. Most Android devices can connect to the Internet in multiple ways, including through 3G (and beyond) networks or Wi-Fi connections. Android applications can use many of the most popular Internet protocols, including HTTP, HTTPS, TCP/IP, and raw sockets.

So far, you have supplied only mock XML data in the Been There, Done That! application. Now it's time to modify the application to contact a remote application server to get live data. To do this, you need to learn about the networking features available on the Android platform, as well as how to offload tasks from the main UI thread and execute them asynchronously.

Two classes of the Been There, Done That! application need to download information from an application:

► QuizScoresActivity—This class needs to download score information.

► QuizGameActivity—This class needs to download each batch of trivia questions.

To enable the Been There, Done That! application to handle live data, you need to access an application server as well as add networking functionality to the client Android application.

The full implementation of the networking code provided in this hour is available on the book's website,

0 0

Post a comment