Before you start
You should be comfortable constructing Android applications with the Android SDK to get the most from this tutorial. After completion, you will have learned how to perform application-to-web server communications with HTTP(S) and how to parse XML with the DOM parser. Along the way, you will create custom and dynamic user interface layouts, multi-threaded communications, message handlers, and progress dialogs. To a lesser degree, you will learn about AndroidManifest.xml and server side scripting.
This tutorial introduces an architecture for dynamic forms for mobile data collection on Android devices. I will begin with a high level architecture and discussion of where such an application fits in the larger context of data collection. A sneak peak at the completed project, including every source file, provides a road map to where the tutorial is taking you. In cooking-show fashion, you build the application from the ground up with each Java class carefully introduced and related to other aspects of the application, most notably the data model upon which this forms engine is constructed. To conclude, you save form data to the server and look briefly at the server side of the application.
Table 1 shows the tools required for this project.
Table 1. The necessary tools for the job
|Eclipse and ADT||Primary code editor and Android Developer Tools Plugin.|
|Android SDK||Android Software Developer Kit.|
|Web server||Any variety that supports PHP. You can easily port the script to another server environment.|
I created the code samples for this tutorial on a MacBook with Eclipse 3.4.2 and Android SDK version 8, which supports the Android release labeled 2.2. The tutorial code is not leveraging any specific features of this SDK and the application should run just fine in Android versions dating back as far as 1.5. See Resources for links to all the tools.