A (175)

(Tuis.) #1

66 CHAPTER 3: An Introduction to the Android Application Development Platform


It is important to note that DVM is still the default (preferred) runtime for the Android OS, and
that ART is included in Android 4.4 and later devices, but it is not initially activated for use as the
primary runtime scheduling utility. This is because ART is new and unproven, whereas the DVM has
withstood the test of time and works adequately, especially given faster CPUs and more memory.
Startiing with Android 5.0, ART will be the default (primary) runtime used for the Android OS.


ART is also a VM and is a runtime utility for the OS just like the DVM is. The main difference is that
whereas DVM uses a JIT model, ART uses an “Ahead of Time” (AOT) model. In the AOT model, the
machine language binary gets created when a user installs the Android app, rather than each time
the user executes (launches or runs) the app. The “pros” of this approach is of course a faster launch
time, which all users love, and the “cons” of this approach is the slower download and install time,
as this now includes the creation of this machine language binary runtime file. Another con would be
the storage space necessary to store this machine language binary, once it is created.


The thought here on the part of Android OS developers is that although during application installation
more processor power and memory will be used (and hence more battery power) to create this binary
machine language runtime module for each installed application, once the user is done installing all of
the apps that they will be using on their Android devices, less battery power, memory, and processing
overhead will be used during the actual day-to-day usage of the Android device.


The next thing that I want to show you is how to create a new Android 4.4 application project. The
reason I am doing this next is so that you have something concrete to look at, once I start talking
about how an Android application goes together, as far as how Java, XML, and your project assets
are used, and where things need to be stored, and how assets are organized within the Android
application project. Organization and structure becomes more and more important, the more
complex your app becomes!


Creating Your First Android Application


By now, you are probably quite eager to fire up Eclipse again, and to create your first Android 4.4.4
application. We need to do this so that you can observe how everything works together when it
comes to creating your own custom Android application.


A time-honored tradition across every programming language is for new users to create a Hello World
application. Let’s create our own Absolute Beginner Hello World Android application, right here and
now. Just so that we do things as “out-of-the-box” as possible, we should call this application “Hello
Universe,” so that we can expand (no pun intended) on it as we move through this book. We will add
all sorts of impressive features that you might find across the universe, were you ever to visit one.


First, we will launch Eclipse, and create the application. Then we will take a look at all of the files that
Eclipse creates for us, as well as the Java and XML code that Eclipse generates to get your app up
and running. We will then examine in detail the resource folder hierarchy for the project structure and
see how Android (Eclipse ADT) wants us to structure our Android project assets (resources).


Finally, we will use the GIMP digital image editing and compositing application to create your custom
application icon. As you probably know, the Android application icon is displayed on Android
devices in the application launch icons area on one of the primary OS screens. After we create a
custom app icon, we’ll use the Nexus One Android Virtual Device (AVD) that we created in Chapter 2
via the Run As Android Application work process, which allows us to test and admire the new Hello
Universe app we are about to create.

Free download pdf