Android Programming: The Big Nerd Ranch Guide
by Bill Phillips , Chris Stewart and Kristin Marsicano
Copyright 2017 Big Nerd Ranch, LLC.
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. For information regarding permissions, contact
Big Nerd Ranch, LLC.
200 Arizona Ave NE
Atlanta, GA 30307
(770) 817-6373
http://www.bignerdranch.com/
book-comments@bignerdranch.com
The 10-gallon hat with propeller logo is a trademark of Big Nerd Ranch, Inc.
Exclusive worldwide distribution of the English edition of this book by
Pearson Technology Group
800 East 96th Street
Indianapolis, IN 46240 USA
http://www.informit.com
The authors and publisher have taken care in writing and printing 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.
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.
ISBN-10 0134706072
ISBN-13 978-0134706078
Third edition, first printing, February 2017
Release E.3.1.1
Dedication
To the record player on my desk. Thanks for keeping me company through all this. I promise Ill get you a new needle soon. |
B.P. |
To my dad, David, for teaching me the value of hard work. To my mom, Lisa, for pushing me to always do the right thing. |
C.S. |
To my dad, Dave Vadas, for inspiring and encouraging me to pursue a career in computing. And to my mom, Joan Vadas, for cheering me on through all the ups and downs (and for reminding me that watching an episode of The Golden Girls always makes things better). |
K.M. |
Acknowledgments
With this being our third edition, we find ourselves used to saying this. It always needs to be said, though: Books are not created by authors alone. They are shepherded into existence by a community of collaborators, risk-takers, and other supporters, without whom the burden of comprehending and writing all this material would be crippling.
Brian Hardy, who, along with Bill, had the gusto to bring the very first edition of this book into the world. From nothing, Brian and Bill made something great.
Our co-instructors and members of our Android development team: Andrew Lunsford, Bolot Kerimbaev, Brian Gardner, David Greenhalgh, Josh Skeen, Matt Compton, Paul Turner, and Rashad Cureton. (Soon, Rashad. Soon.) They taught everything in this book before it was polished enough to be presentable and gave us many invaluable suggestions and corrections. Most people live their entire lives without ever working with such a talented and entertaining crew. They make work at Big Nerd Ranch an everyday joy.
Special thanks to Andrew, who went through the entire book and updated all the Android Studio screenshots. We appreciate his thoroughness, attention to detail, and acerbic wit.
Zack Simon, our fantastically talented and soft-spoken Big Nerd Ranch designer. Unbeknownst to us, Zack went behind our backs and updated the nifty cheat sheet you can find attached to this book. If you enjoy that sheet, you should find Zack and tell him so yourself. But we will also thank Zack right here: Thanks, Zack!
Kar Loong Wong, for his work redesigning the crime list screen. The more help we get from Kar, the better the apps in this book look. Thanks, Kar.
Mark Dalrymple, who reviewed our constraint layout coverage for accuracy and wonderfulness. If you happen to run into Mark, ask him to review your constraint layout coverage. He is so good at doing that! But if you have none, ask him to make balloon animals for you instead.
Thanks to Aaron Hillegass. As a practical matter, it is not possible to do this work without Big Nerd Ranch, the company Aaron founded. Thank you.
Our editor, Elizabeth Holaday. The famous beat author William S. Burroughs sometimes wrote by cutting up his work into little pieces, throwing them in the air, and publishing the rearrangement. Without a strong editor like Liz, our confusion and simpleminded excitement may have caused us to resort to such techniques. We are thankful that she was there to impose focus, precision, and clarity on our drafts.
Ellie Volckhausen, who designed our cover.
Anna Bentley, our copyeditor, and Simone Payment, our proofreader. Thank you both for sanding away the remaining rough edges of this book.
Chris Loper at IntelligentEnglish.com, who designed and produced the print and ebook versions of the book. His DocBook toolchain made life much easier, too.
Finally, thanks to our students. There is a feedback loop between us and our students: We teach them out of these materials, and they respond to it. Without that loop, this book could never have existed, nor could it be maintained. If Big Nerd Ranch books are special (and we hope they are), it is that feedback loop that makes them so. Thank you.
Learning Android
As a beginning Android programmer, you face a steep learning curve. Learning Android is like moving to a foreign city. Even if you speak the language, it will not feel like home at first. Everyone around you seems to understand things that you are missing. Things you already knew turn out to be dead wrong in this new context.
Android has a culture. That culture speaks Java, but knowing Java is not enough. Getting your head around Android requires learning many new ideas and techniques. It helps to have a guide through unfamiliar territory.
Thats where we come in. At Big Nerd Ranch, we believe that to be an Android programmer, you must:
This guide will help you do both. We have trained thousands of professional Android programmers using it. We lead you through writing several Android applications, introducing concepts and techniques as needed. When there are rough spots, or when some things are tricky or obscure, you will face them head on, and we will do our best to explain why things are the way they are.
This approach allows you to put what you have learned into practice in a working app right away rather than learning a lot of theory and then having to figure out how to apply it all later. You will come away with the experience and understanding you need to get going as an Android developer.
Prerequisites
To use this book, you need to be familiar with Java, including classes and objects, interfaces, listeners, packages, inner classes, anonymous inner classes, and generic classes.
If these concepts do not ring a bell, you will be in the weeds by page 2. Start instead with an introductory Java book and return to this book afterward. There are many excellent introductory books available, so you can choose one based on your programming experience and learning style.