Table of Contents
Introduction
Learning to develop software is like learning to ride a bike: you will not get very far unless you hop on and start pedaling. This book focuses on development in much the same way. Each chapter will introduce new, core concepts to Android and follow with code samples. I find that I learn best by sitting down and writing code. I encourage you to follow this book with your computer, writing and testing code as you go. Please view this book more as a guide to follow than a textbook to memorize.
The first two parts of the book will walk you through developing and extending a single, core app. Each chapter in these parts is designed to continue building on the one before. The final three parts compartmentalize the topics, providing functional sample code that can be run independently. All chapters are brief and designed to focus on the most important content in-depth while still providing contextual information for the whole topic.
Developing Android apps is an exciting space to occupy. New Android devices and features are developed rapidly, providing you with new platforms and capabilities to implement your ideas. You may or may not already be familiar with Java and the Eclipse development environment, but you will likely enjoy meeting the new challenges that Android has to offer. From the nuances of the development kit and Androids unique operating system mechanics to publishing your app in the Market, you have a wealth of fun opportunities to learn ahead of you.
Conventions Used in This Book
When you need to write code in Android, it takes one of two forms: XML or Java. With XML, all code samples in this book have the following syntax:
All Java code is formatted like this:
The steps of instructions are formatted in bold. For example, to create a new Android project in Eclipse, select File > New > Android Project from the menu.
How This Book is Organized
This book is divided into five parts. The first few chapters introduce Android and its capabilities, the preferred developer tools, and the Android SDK, which you use as the basis for your app development. Once you have your first app built and running, the chapters introduce laying out your app, working with resources, and building user interfaces. As you become comfortable working with screens and widgets, you learn how to incorporate core hardware features like the camera and location services. After you have explored localization and databases, you will be ready to prepare your app for the Android Market.
Part 1: Getting Started. Here you download the Android SDK and developer tools to begin building your apps. Get acquainted with Eclipse and the Android emulator, tools you use in every step of the process. You write your first app and explore Java and the Android SDK.
Part 2: Constructing Your Application. Accelerate the development of your user interfaces with animations and dialogs. You learn how to store and retrieve information, and how to provide search capability. Fundamental concepts in user interaction are covered in this part.
Part 3: Make the Most of the Hardware. Android devices are chock full of powerful hardware features. From location services to Bluetooth and cameras to 3D animation, here you learn how to allow your app to make the most of its physical device.
Part 4: Increasing Your Application Scope. One of your goals as an app developer is probably to reach as large an audience as possible. This part demonstrates how to localize your app for different languages and regions, store data more efficiently, and how to enable your app to communicate with other Android apps.
Part 5: Taking Your App to Market. If you have started app development, you likely want to be able to distribute your app. The Android Market is the largest Android app storefront in the world, and this part takes you through the process of preparing your app for Market. By fixing errors through debugging and testing your app, you will be ready to begin the process of submitting your app for public consumption.
Extras
Throughout the book you will see sidebars that elaborate on keywords, principles, and ideas.
DEFINITION
Key terms in Android app development.
PITFALL
Tips to avoid common mistakes.
ANDROID DOES
Advice to save you time and effort.
GOOGLE IT
Interesting factoids to encourage your development growth.
Acknowledgments
I would like to thank my wife Heather and my son Eli, who have gone above and beyond in supporting me through the adventure of writing this book. Thank you both for your encouragement.
Additionally, thank you David, Phil, and Steve for your support and guidance.
Special Thanks to the Technical Reviewer
The Complete Idiots Guide to Android App Development was reviewed by an expert who double-checked the accuracy of what youll learn here, to help us ensure that this book gives you everything you need to know about Android development. Special thanks to Cliff Lardin and Damon Brown.
Trademarks
All terms mentioned in this book that are known to be or are suspected of being trademarks or service marks have been appropriately capitalized. Alpha Books and Penguin Group (USA) Inc. cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.
Part 1
Getting Started
How do you get started writing apps for Android? What software do you need? What programming languages does Android support? How do you get started with Eclipse?
This part answers these questions and begins your transition into Android development. By the end of this part, you will be familiar with Eclipse and creating your first Android apps.
Chapter 1
An Open Invitation
In This Chapter
What you need to get started
Android features and limitations
The Android Software Development Kit (SDK)
As a software developer, I spend a lot of time with other developers brainstorming application ideas. Imagine a laser tag application that runs on your mobile phone, uses GPS coordinates to locate you and all of your friends, then layers their profile pictures over a street view map of your area. Using a digital compass and accelerometers, you can play virtual laser tag all over your home town. Neither the software nor the hardware existed years ago when I first imagined this type of app, but Googles Android OS has changed many of our perceptions about what is possible.