Head First Android Development
by Dawn Griffiths and David Griffiths
Copyright 2017 Dawn Griffiths, David Griffiths. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com/safari). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editor: Dawn Schanafelt
- Production Editor: Kristen Brown
- Proofreader: Rachel Monaghan
- Indexer: Angela Howard
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Rebecca Demarest
- August 2017: Second Edition
Revision History for the Second Edition
See http://oreilly.com/catalog/errata.csp?isbn=9781491974056 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Head First Android Development, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-491-97405-6
[M]
To our friends and family. Thank you so much for all your love and support.
Authors of Head First Android Development
Dawn Griffiths started life as a mathematician at a top UK university, where she was awarded a first-class honors degree in mathematics. She went on to pursue a career in software development and has over 20 years experience working in the IT industry.
Before writing Head First Android Development, Dawn wrote three other Head First books (Head First Statistics, Head First 2D Geometry, and Head First C). She also created the video course The Agile Sketchpad with her husband, David, to teach key concepts and techniques in a way that keeps your brain active and engaged.
When Dawns not working on Head First books or creating videos, youll find her honing her Tai Chi skills, reading, running, making bobbin lace, or cooking. She particularly enjoys spending time with her wonderful husband, David.
David Griffiths began programming at age 12, when he saw a documentary on the work of Seymour Papert. At age 15, he wrote an implementation of Paperts computer language LOGO. After studying pure mathematics at university, he began writing code for computers and magazine articles for humans. Hes worked as an Agile coach, a developer, and a garage attendant, but not in that order. He can write code in over 10 languages and prose in just one, and when not writing, coding, or coaching, he spends much of his spare time traveling with his lovely wifeand coauthorDawn.
Before writing Head First Android Development, David wrote three other Head First booksHead First Rails, Head First Programming, and Head First Cand created The Agile Sketchpad video course with Dawn.
You can follow us on Twitter at https://twitter.com/HeadFirstDroid and visit the books website at https://tinyurl.com/HeadFirstAndroid.
How to use this Book: Intro
Note
In this section, we answer the burning question: So why DID they put that in a book on Android?
Who is this book for?
If you can answer yes to all of these:
Do you already know how to program in Java?
Do you want to master Android app development, create the next big thing in software, make a small fortune, and retire to your own private island?
Note
OK, maybe that ones a little far-fetched. But you gotta start somewhere, right?
Do you prefer actually doing things and applying the stuff you learn over listening to someone in a lecture rattle on for hours on end?
this book is for you.
Who should probably back away from this book?
If you can answer yes to any of these:
Are you looking for a quick introduction or reference book to developing Android apps?
Would you rather have your toenails pulled out by 15 screaming monkeys than learn something new? Do you believe an Android book should cover everything, especially all the obscure stuff youll never use, and if it bores the reader to tears in the process, then so much the better?
this book is not for you.
We know what youre thinking
How can this be a serious book on developing Android apps?
Whats with all the graphics?
Can I actually learn it this way?
We know what your brain is thinking
Your brain craves novelty. Its always searching, scanning, waiting for something unusual. It was built that way, and it helps you stay alive.
So what does your brain do with all the routine, ordinary, normal things you encounter? Everything it can to stop them from interfering with the brains real jobrecording things that matter. It doesnt bother saving the boring things; they never make it past the this is obviously not important filter.
How does your brain know whats important? Suppose youre out for a day hike and a tiger jumps in front of youwhat happens inside your head and body?
Neurons fire. Emotions crank up. Chemicals surge.
And thats how your brain knows...
This must be important! Dont forget it!
But imagine youre at home or in a library. Its a safe, warm, tiger-free zone. Youre studying. Getting ready for an exam. Or trying to learn some tough technical topic your boss thinks will take a week, ten days at the most.
Just one problem. Your brains trying to do you a big favor. Its trying to make sure that this obviously unimportant content doesnt clutter up scarce resources. Resources that are better spent storing the really big things. Like tigers. Like the danger of fire. Like how you should never have posted those party photos on your Facebook page. And theres no simple way to tell your brain, Hey brain, thank you very much, but no matter how dull this book is, and how little Im registering on the emotional Richter scale right now, I really