Introduction to Android

14-03-17 Admin 0 comment

1.1 Introduction Welcome to Android app development! We hope that you’ll find working with Android for Programmers: An App-Driven Approach to be an informative, challenging, entertaining and rewarding experience. This book is geared toward Java programmers. We use only complete working apps, so if you don’t know Java but have object-oriented programming experience in another language, such as C#, Objective-C/Cocoa or C++ (with class libraries), you should be able to master the material quickly, learning Java and Java-style object oriented programming as you learn Android app development.

The book uses an app-driven approach—we discuss each new technology in the context of complete working Android apps, with one app per chapter. We describe the app and test-drive it. Next, we briefly overview the key Eclipse (integrated development environment), Java and Android SDK (Software Development Kit) technologies we’ll use to implement the app. For apps that require it, we walk through designing the GUI visually using Eclipse. Then we provide the complete source-code listing, using line numbers, syntax shading (to mimic the syntax coloring used in the Eclipse IDE) and code highlighting to emphasize the key portions of the code. We also show one or more screenshots of the running app. Then we do a detailed code walkthrough, emphasizing the new programming concepts introduced in the app. The source code for all of the book’s apps can be downloaded from Figure 1.1 lists key online Android documentation.



Read the Before You Begin section following the Preface for information on downloading the software you’ll need to build Android apps. The Android Developer site provides free downloads plus documentation, how-to videos (Fig. 1.38), coding guidelines and more. To publish your apps to Google’s app marketplace—Android Market—you’ll need to create a developer profile at There’s a registration fee and you must agree to the Android Market Developer Distribution Agreement. We discuss publishing your apps in more detail in Chapter 2, Android Market and App Business Issues. As you dive into Android app development, you may have questions about the tools, design issues, security and more. There are several Android developer newsgroups and forums where you can get the latest announcements or ask questions (Fig. 1.2).


Android Overview

The first-generation Android phones were released in October 2008. According to Gartner, North American sales of Android-based phones increased 707% in the first quarter of 2010 over the previous year.1 By March 2011, a Nielsen study showed that Android had 37% of the U.S. smartphone market share, compared to 27% for Apple’s iPhone and 22% for Blackberry.2 In August 2010, more than 200,000 Android smartphones were being activated each day, up from 100,000 per day only two months earlier.3 As of May 2011, more than 400,000 Android devices were being activated daily. There are now over 300 different Android devices worldwide. The Android operating system was developed by Android, Inc., which was acquired by Google in July 2005. In November 2007, the Open Handset Alliance™—a consortium of 34 companies initially and 81 now (Fig. 1.3)—was formed to develop Android, driving innovation in mobile technology and improving the user experience while reducing costs. Android is used in numerous smartphones, e-reader devices, and tablet computers.

Open Handset Alliance members ( oha_members.html)

Openness and Open Source One benefit of developing Android apps is the openness of the platform. The operating system is open source and free. This allows you to view Android’s source code and see how its features are implemented. You can also contribute to Android by reporting bugs (see or by participating in the Open Source Project discussion groups ( Numerous open-source Android apps from Google and others are available on the Internet (Fig. 1.4). Figure 1.5 shows you where you can get the Android source code, learn about the philosophy behind the open-source operating system and get licensing information.

Java Android apps are developed with Java—the world’s most widely used programming language. Java—the world’s most widely used programming language—was a logical choice for the Android platform, because it’s powerful, free and open source. Java is used to develop large-scale enterprise applications, to enhance the functionality of web servers, to provide applications for consumer devices (e.g., cell phones, pagers and personal digital assistants) and for many other purposes. Java enables you to develop apps that will run on a variety of devices without any platform-specific code. Experienced Java programmers can quickly dive into Android development, using the Android APIs (Application Programming Interfaces) and others available from third parties. The openness of the platform spurs rapid innovation. Android is available on devices from dozens of original equipment manufacturers (OEMs) in 48 countries through 59 carriers.4 The intense competition among OEMs and carriers benefits customers.

Java is object oriented and has access to powerful class libraries that help you develop apps quickly. GUI programming in Java is event driven—in this book, you’ll write apps that respond to various user-initiated events such as screen touches and keystrokes. In addition to directly programming portions of your apps, you’ll also use Eclipse to conveniently drag and drop predefined objects such as buttons and textboxes into place on your screen, and label and resize them. Using Eclipse with the Android Development Tools (ADT) Plugin, you can create, run, test and debug Android apps quickly and conveniently, and you can visually design your user interfaces. Multitouch Screen Many Android smartphones wrap the functionality of a mobile phone, Internet client, MP3 player, gaming console, digital camera and more into a handheld device with full-color multi-touch screens. These allow you to control the device with gestures involving one touch or multiple simultaneous touches (Fig. 1.6).

Using the multitouch screen, you can navigate easily between your phone, apps, music library, web browsing, and so on. The screen can display a keyboard for typing emails and text messages and entering data in apps (some Android devices also have hard keyboards). Using two fingers, you can zoom in (moving your fingers apart) and out (pinching your fingers together) on photos, videos and web pages. You can scroll up and down or side to side by just swiping your finger across the screen. Built-in Apps Android devices come with several built-in apps, which may vary depending on the device. These typically include Phone, Contacts, Mail, Browser and more (Fig. 1.7). Many manufacturers customize the default apps; we’ll show you how to interact with the apps regardless of how they’ve been changed.

Android Naming Convention

Each new version of Android is named after a dessert, going in alphabetical order:

• Android 1.6 (Donut)

• Android 2.0–2.1 (Eclair)

• Android 2.2 (Froyo)

• Android 2.3 (Gingerbread)

• Android 3.0 (Honeycomb)

to be continued….


Leave a reply