Introduction to Android
App Development for the Kindle Fire
Lauren Darcey
Shane Conder
Upper Saddle River, NJ Boston Indianapolis San Francisco
New York Toronto Montreal London Munich Paris Madrid
Cape Town Sydney Tokyo Singapore Mexico City
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
Android is a trademark of Google, Inc. Kindle Fire is a trademark of Amazon.com, Inc.
Android and Google are trademarks of Google, Inc. Kindle Fire and Amazon.com are trademarks of Amazon.com, Inc. Neither Amazon.com, Inc., nor Google, Inc., have authorized or approved publication of this work and references to their marks herein are not intended to imply their sponsorship or affiliation with this work.
Visit us on the web: informit.com/aw
Copyright 2012 Lauren Darcey and Shane Conder
All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458, or you may fax your request to (201) 236-3290.
ISBN-13: 978-0-133-04047-0
ISBN-10: 0-133-04047-X
First publication: April 2012
Acquisitions Editor
Laura Lewin
Senior Development Editor
Chris Zahn
Managing Editor
Kristy Hart
Project Editor
Jovana San Nicolas-Shirley
Copy Editor
Sheri Cain
Technical Reviewer
Ray Rischpater
Publishing Coordinator
Olivia Basegio
For Ellie
Preface
Key Features of This Book
This mini-book covers Android Fundamentals for Kindle Fire application development. Here, you are introduced to Android, become familiar with the Android SDK and tools, install the development tools, and write your first Android application and deploy it to a Kindle Fire device. You are also introduced to the design principles necessary to write Android applications, including how Android applications are structured and configured, as well as how to incorporate application resources, such as strings, graphics, and user interface components, into your projects.
If you like this mini-book, we recommend continuing with the full version of the text, which provides a full hands-on tutorial for developing a real Kindle Fire application from start to finish. The full edition of this book is available in print and as an e-book.
Target Audience for This Book
Theres no reason anyone with an Android device, a good idea for a mobile application, and some programming knowledge couldnt put this book to use for fun and profit. Whether youre a programmer looking to break into mobile technology or an entrepreneur with a cool app idea, this book can help you realize your goals of making killer Android apps.
We make as few assumptions about you, as a reader of this book, as possible. No wireless development experience is necessary. We do assume that youre somewhat comfortable installing applications on a computer (for example, Eclipse, the Java JDK, and the Android SDK) and tools and drivers (for USB access to a phone). We also assume that you own at least one Android device and can navigate your way around it for testing purposes.
Android apps are written in Java. Therefore, we assume you have a reasonably solid understanding of the Java programming language (classes, methods, scoping, OOP, and so on), ideally using the Eclipse development environment. Familiarity with common Java packages, such as java.lang
, java.net
, and java.util
, will serve you well.
Android can also be a fantastic platform for learning Java, provided you have some background in object-oriented programming and adequate support, such as a professor or some really good Java programming references. We have made every attempt to avoid using any fancy or confusing Java in this book, but you will find that with Android, certain syntactical Java wizardry not often covered in your typical beginners Java book is used frequently: anonymous inner classes, method chaining, templates, reflection, and so on. With patience, and some good Java references, even beginning Java developers should be able to make it through this book alive; those with a solid understanding of Java should be able to take this book and run with it without issue.
Finally, regardless of your specific skill set, we expect you to use this book in conjunction with other supplementary resources, specifically the Android SDK reference and the sample source code that accompanies each coding chapter. The Android SDK reference provides exhaustive documentation about each package, class, and method of the Android SDK. Its searchable online. If we were to duplicate this data in book form, this book would weigh a ton, literally.
Development Environment Used In This Book
The code in this book was written and tested using the following development environments:
Windows 7 and Mac OS X 10.6.7.
Eclipse Java IDE Version 3.7 (Indigo).
Android ADT plug-in for Eclipse, 16.0.1.
Android SDK Tools, Release 16.
Sun Java SE Development Kit (JDK) 6 Update 21.
Code examples target Android SDK API Level 10.
The code was tested on the original Android Kindle Fire (Android SDK 2.3.4, API Level 10).
Code Examples for This Book
This source code is also available for download on the publisher website (http://www.informit.com/title/9780133040470) and on the authors website (http://androidbook.blogspot.com/p/book-code-downloads.html).
We provide complete, functional code projects for each coding chapter in this book. If you have trouble building the tutorial application as you go along, compare your work to the sample code for that chapter. The sample code is not intended to be the answer, but it is the complete code listings that could not otherwise be reproduced in a book of this length.
What Is (and Isnt) in This Book
First and foremost, this book provides a thorough introduction to the Android platform for Kindle Fire application development. In this mini-book, we begin with the fundamentals, try to cover the most important aspects of development, and provide information on where to go for more information. This is not an exhaustive reference on the Android SDK. We assume that you will use this book as a companion to the Android SDK documentation, available for download as part of the SDK and online at http://developer.android.com.
We only have six chapters to get you, the reader, up to speed on the fundamentals of Android development, so forgive us if we stay strictly to the topic at hand. Therefore, we take the prerequisites listed earlier seriously. This book will not teach you how to program, explain Java syntax and programming techniques, or stray too far into the details of supporting technologies often used by mobile applications, like algorithm design, network protocols, developing web servers, graphic design, database schema design, and other such peripheral topics; there are fantastic references available on each of these subjects.