Practical Android Projects - Jordon, Greyling - Apress (2011).pdf

(17189 KB) Pobierz
Building cool scripts, apps, and games
for Android Smartphones
Practical
Android Projects
Lucas Jordan | Pieter Greyling
813313861.044.png 813313861.055.png 813313861.066.png 813313861.072.png 813313861.001.png 813313861.002.png 813313861.003.png 813313861.004.png 813313861.005.png 813313861.006.png 813313861.007.png 813313861.008.png 813313861.009.png 813313861.010.png 813313861.011.png 813313861.012.png 813313861.013.png 813313861.014.png 813313861.015.png 813313861.016.png 813313861.017.png 813313861.018.png 813313861.019.png 813313861.020.png 813313861.021.png 813313861.022.png 813313861.023.png 813313861.024.png 813313861.025.png 813313861.026.png 813313861.027.png 813313861.028.png 813313861.029.png 813313861.030.png 813313861.031.png 813313861.032.png 813313861.033.png 813313861.034.png 813313861.035.png 813313861.036.png 813313861.037.png 813313861.038.png 813313861.039.png 813313861.040.png 813313861.041.png 813313861.042.png 813313861.043.png 813313861.045.png 813313861.046.png 813313861.047.png 813313861.048.png 813313861.049.png 813313861.050.png 813313861.051.png 813313861.052.png 813313861.053.png
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
813313861.054.png 813313861.056.png 813313861.057.png 813313861.058.png 813313861.059.png 813313861.060.png 813313861.061.png 813313861.062.png
Contents at a Glance
Contents .......................................................................................................... v
About the Authors ........................................................................................... x
About the Technical Reviewer........................................................................ xi
Acknowledgments ......................................................................................... xii
Preface ......................................................................................................... xiii
Chapter 1: Android Fundamentals................................................................... 1
Chapter 2: Development Tools in Practice .................................................... 49
Chapter 3: Roll Your Own Android Scripting Environment .......................... 105
Chapter 4: Embedding Lua in Android Applications .................................... 155
Chapter 5: Introducing SL4A: The Scripting Layer for Android ................. 193
Chapter 6: Creating a GUI with HTML/JavaScript and AIR .......................... 221
Chapter 7: Using REST with Facebook and Twitter ..................................... 251
Chapter 8: Using the Google App Engine with Android................................ 275
Chapter 9: Game Development: Graphics .................................................... 311
Chapter 10: Game Development: Animation ................................................ 341
Chapter 11: App Inventor ............................................................................ 361
Index ............................................................................................................ 387
iv
813313861.063.png 813313861.064.png 813313861.065.png 813313861.067.png 813313861.068.png 813313861.069.png
 
1
1
Chapter
Android Fundamentals
The Android platform is a very exciting yet relatively new player in today’s mobile device
market. Beyond rating very highly in the number of cool features per device, Android-
enabled smartphones are currently enjoying the highest percentage sales growth rate in
the mobile industry.
According to Gartner Research, 1 worldwide sales of Android-based smartphones to end
users have jumped from the number 6 spot in 2009 to number 4 by the end of the first
quarter of 2010. This level of growth is expected to continue. In fact, Gartner has
predicted that Android will become the number 2 worldwide mobile operating system in
2010 and will challenge Symbian for the number 1 position by 2014. 2
We want to share with you some of the enthusiasm we have for this truly remarkable
development platform. Throughout the course of this book, we will attempt to do this by
showing the wide range of opportunities available at your fingertips when you choose to
develop Android applications.
Perhaps you are reading this book in order to gain more background understanding of
the Android platform. Perhaps you plan to roll up your sleeves and join us in running and
playing with the projects in the emulator or your own device. We want to get you up and
running quickly and provide you with sufficient understanding of the Android platform
and Android Development Kit (ADK) development environment to have success with
your goals.
With those goals in mind, this chapter aims to be as practical an introduction to Android
development as possible. It also strives to cover a broad spectrum of required
conceptual and theoretical background material in a concise and to-the-point manner.
We will start with a short description of the Android platform and then jump straight into
coverage of the installation of the Android SDK and supporting development tools. To
fully round out our SDK setup study, we embark on a step-by-step test drive that
1 From Gartner press release: http://www.gartner.com/it/page.jsp?id=1372013
2 From the Gartner press release: http://www.gartner.com/it/page.jsp?id=1434613
1
813313861.070.png
2
CHAPTER 1: Android Fundamentals
involves generating a bare-bones Android project and getting the resulting skeleton
Android application up and running in the Android emulator.
The next order of business will be a tour of the Android platform architecture. Here we
will describe the Android platform stack; Android component architecture; and Dalvik,
the Android runtime. With this knowledge in hand, we then cover working with the Java
IDEs Eclipse, NetBeans, and IntelliJ IDEA Community Edition; plus spend some time
learning how to equip them with Android programming capabilities via plugins.
This means we have a lot of ground to cover, so let's get started.
What Is Android?
In a nutshell, Android is an operating system targeted at mobile hardware such as
phones and other constrained computing devices such as netbooks and tablet
computers.
The concept and platform was the brainchild of Android Inc., a small startup company
from Palo Alto, California, that was acquired by Google in 2005. Its stated goal was to
create a small, stable, flexible, and easily upgraded operating system for handsets that
would be highly attractive for device manufacturers and telephony carriers.
Android platform releases 1.x through 2.x are aimed primarily at smartphone devices,
whereas it is reported that Android release 3.x will be the first operating platform
specifically designed with high-end support for tablet computers.
The Android platform was originally unveiled in November 2007. The unveiling coincided
with the announcement of the formation of the Open Handset Alliance, a group of
companies that share the goal of promoting open standards for mobile device platforms
such as Android.
In October 2008, Android was released under the Apache 2.0 open-source license. 3 This
and the flexible component-based design of the platform present innovative and cost-
effective opportunities for manufacturers and software developers alike. We aim to
showcase some of these distinguishing platform capabilities during the course of this
book.
Installing the Android SDK
We will start by installing the core Android SDK and tools. Our aim is to get the Android
emulator with our own simple application up and running on an Android Virtual Device
(AVD) as soon as possible. The experience gained will then serve as a basis for further
discussion.
813313861.071.png
Zgłoś jeśli naruszono regulamin