The application architecture
Before diving into the code, examine the application setting from a very high level.
Take a walk through all of the aspects of the Forms Engine application. Figure 1 depicts the relation of the application to one or more servers that provide data entry forms of varying content.
Figure 1. Application architecture
In Figure 1, Form 1 provides registration for Robotics Competition and Form 2 asks the user for information about his auto maintenance habit. Using HTTP(S), the forms and Android application communicate to:
- Download the form data.
- Present form data to the user and optional collect device-specific data, such as camera images, sound recordings, GPS location, or compass readings.
- Collect user-supplied data.
- Submit data to the appropriate server.
The server side of this tutorial is implemented as a pair of files: an XML document describing the form and a PHP document responsible for recording the submission of the form. The Android application is a native application written in Java code using the Android SDK and coded in Eclipse.
Table 2 shows the application source files for the complete application. You can download the zipped file containing all of these source files (see Downloads). You will go through each of these files in detail in this tutorial.
Table 2. The required application source files
|XmlGui.java||Entry point for Android Activity|
|XmlGuiForm.java||High level data model and methods for a form|
|XmlGuiFormField.java||Represents a form field and holds the metadata for each field of a form|
|XmlGuiEditBox.java||Implements a text box type user interface element|
|XmlGuiPickOne.java||Implements a drop-down list type user interface element|
|RunForm.java||Processes a form, using the above classes|
|main.xml||Home page of application user interface|
|AndroidManifest.xml||Deployment descriptor for the Android application|
|xmlgui1.xml||Sample form for collecting Robotics competition registration|
|xmlgui1-post.php||PHP script for processing form submissions|
|xmlgui2.xml||Sample form for taking survey of automotive maintenance habits|
Figure 2. Project in Eclipse
If you do not have a working Android development environment, now is a great time to install the Android tools. For more information on how to setup an Android development environment, look in Resources for links to both of the required tools, plus some introductory articles and tutorials on developing applications for Android. Having a familiarity with Android is helpful in understanding this tutorial.
Now that you have an overview of the architecture and the application, you can get started!