What readers are saying about Hello, Android
This is a most excellent book: very well written, easy to read, and fun.
In addition, any of Android’s quirks are explained along with just the
right amount of detail to ensure quality programming principles are
followed.
Anthony Stevens
Founder and CTO, PocketJourney and Top 20 Winner of
Google Android Competition
Ed Burnette covers an impressive amount of ground in a nicely com-
pact book while retaining the popular Pragmatic style. For the mate-
rial on 2D and 3D graphics alone, this is worthy of a spot in any
Android developer’s library.
Mark Murphy
Founder, CommonsWare
I remember when I first started to work with Android; it was like a
huge maze. With this book, the introduction would have been much
less painful. I am convinced that by reading this book new Android
programmers will have an easier start.
Gabor Paller
Senior Software Architect, OnRelay, Ltd.
Hello, Android
Intr oducing Google’s
Mobile Development Platform
Ed Burnette
The Pragmatic Bookshelf
Raleigh, North Carolina Dallas, Texas
Many of the designations used by manufacturers and sellers to distinguish their prod-
ucts are claimed as trademarks. Where those designations appear in this book, and The
Pragmatic Programmers, LLC was aware of a trademark claim, the designations have
been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The
Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g
device are trademarks of The Pragmatic Programmers, LLC.
Portions of the book’s cover are reproduced from work created
and shared by Google and
used according to terms described in the Creative Commons 2.5 Attribution License. See
http://code.google.com/policies.html#restrictions for details.
Every precaution was taken in the preparation of this book. However, the publisher
assumes no responsibility for errors or omissions, or for damages that may result from
the use of information (including program listings) contained herein.
Our Pragmatic courses, workshops, and othe r products can help you and your team
create better s oftware and have more fun. For more information, as well as the latest
Pragmatic titles, please visit us at
http://www.pragprog.com
Copyright
©
2
008 Ed Burnette.
All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmit-
ted, in any form, or by any means, electronic, mechanical, photocopying, recording, or
otherwise, without the prior consent of the publisher.
Printed in the United States of America.
ISBN-10: 1-934356-17-4
ISBN-13: 978-1-934356-17-3
Printed on acid-free paper.
P1.5 printing, July 21, 2009
Version: 2009-7-21
Contents
Acknowledgments 10
Changes (Cupcake Updates) 11
P1.5—July 21 ............................ 11
P1.4—July 6 ............................. 11
P1.3—June 22 ............................ 12
P1.2—June 9 ............................ 12
P1.1—May 26 ............................ 12
TODO in future releases ...................... 13
Preface 14
What Makes Android Special? ................... 14
Who Should Read This Book? ................... 15
What’s in This Book? ........................ 16
What’s New for Cupcake? ..................... 16
Online Resources .......................... 17
Fast-Forward >> ........................... 17
I Introducing Android 19
1 Quick Start 20
1.1 Installing the Tools ..................... 20
1.2 Creating Your First Program ................ 24
1.3 Running on the Emulator ................. 24
1.4 Running on a Real Phone ................. 29
1.5 Fast-Forward >> ....................... 29
2 Key Concepts 30
2.1 The Big Picture ....................... 30
2.2 It’s Alive! ........................... 35
2.3 Building Blocks ....................... 39
2.4 Using Resources ....................... 40