Up Previous Next Title Page Contents

5.3.2 Changes to Support Android

The original Watch example was designed to run in a Java applet. Having existing generators for producing valid Java for the application code, changes were needed for the UI and application lifecycle parts. Android applications run as activities, each providing some on-screen function or interaction for the user. For a Watch application, the initial screen and all watch models are activities that are started and stopped during the application lifecycle.

The Java applet version creates the UI dynamically when the applet is started. The Android SDK uses an XML layout file for the layout and view hierarchy. The mechanism of creating the view dynamically was kept because it required the minimum amount of changes and additions to the Watch metamodel and generators.

The only additions to the metamodel were the option for Android in the list of generation target platforms, and the framework classes among the included components. There was no need for changes in models and the core of the generators also stayed the same, since the included components and generators use the existing subgenerators. Additions were made to the prebuild and make phases. The ‘_prebuild for Java: Android’ generator creates the necessary folder structure, while the ‘_create make for Java: Android’ generator creates a batch file that compiles the project, creates and launches the emulator, and installs and launches the application in the emulator. The Eclipse integration makes the generator write additional project property files for Eclipse.

Up Previous Next Title Page Contents