Chapter 3. The Ingredients of an Android Application

Based on the foundation laid in the last chapter for writing robust Java code, this chapter introduces the major high-level concepts involved in programming for the Android platform.

Traditional Programming Models Compared to Android

When starting applications, operating systems traditionally use a single entry point, often called main, which might parse some command-line arguments and then proceed to execute a loop that would read user input and produce output. The OS would load the program code into a process and then start executing it. Conceptually, this kind of process would look something like Figure 3-1.

A simple application in a process
Figure 3-1. A simple application in a process

With programs written in Java, it gets a little more complex: a Java virtual machine (VM) in a process loads bytecode to instantiate Java classes as the program uses them. This process looks something like Figure 3-2. If you use a rich graphical user interface system like Swing, you might start a UI system and then write callbacks to your code that process events.

A Java application, running in a Java virtual machine, in a process
Figure 3-2. A Java application, running in a Java virtual machine, in a process

Android introduces a richer and more complex approach by supporting multiple application entry points. Android programs should expect the system ...

Get Programming Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.