Java Programming for Android Developers For Dummies
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com
Copyright 2014 by John Wiley & Sons, Inc., Hoboken, New Jersey
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions .
Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. Java is a registered trademark of Oracle America, Inc. Android is a trademark of Google, Inc. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit www.wiley.com/techsupport .
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com . For more information about Wiley products, visit www.wiley.com .
Library of Congress Control Number: 2013948033
ISBN 978-1-118-50438-3 (pbk); ISBN 978-1-118-61212-5 (ebk); ISBN 978-1-118-61214-9 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
Introduction
A ndroid is everywhere. In mid-2013, Android ran on 53 percent of all smartphones in the United States and on 80 percent of all smartphones worldwide. In a study that spans the Americas, Europe, Asia, and the Middle East, GlobalWebIndex reports that Android tablets outnumber iPads by 34 million. More than a million apps are available for download at the Google Play store (double the number of apps that were available in May 2012). And more than 9 million developers write code using Java, the language that powers Android devices.
If you read this book in a public place (on a commuter train, at the beach, or on the dance floor at the Coyote Ugly saloon, for example), you can read proudly, with a chip on your shoulder and with your head held high. Android is hot stuff, and youre cool because youre reading about it.
See www.kantarworldpanel.com/global/News/news-articles/Samsung-nears-50-share-across-Europe-as-Apple-powers-back-in-the-US
and http://www.idc.com/getdoc.jsp?containerId=prUS24257413
.
See www.globalwebindex.net/android-tablets-dominate-q1-mobile-market
.
See www.androidguys.com/2013/07/24/sundar-pichai-there-are-now-more-than-1-million-android-apps
.
See www.java.com/en/about
.
How to Use This Book
You can attack this book in either of two ways: go from cover to cover or poke around from one chapter to another. You can even do both (start at the beginning, and then jump to a section that particularly interests you). This book was designed so that the basic topics come first, and the more-involved topics follow them. But you may already be comfortable with some basics, or you may have specific goals that dont require you to know about certain topics.
In general, my advice is this:
If you already know something, dont bother reading about it.
If youre curious, dont be afraid to skip ahead. You can always sneak a peek at an earlier chapter if you need to do so.
Conventions Used in This Book
Almost every technically themed book starts with a little typeface legend, and Java Programming For Android Developers For Dummies is no exception. What follows is a brief explanation of the typefaces used in this book:
New terms are set in italics.
If you need to type something thats mixed in with the regular text, the characters you type appear in bold. For example: Type MyNewProject in the text field.
You also see this computerese
font. I use computerese for Java code, filenames, onscreen messages, and other such things. Also, if something you need to type is really long, it appears in computerese font on its own line (or lines).
You may need to change certain things when you type them on your own computer keyboard. For instance, I may ask you to type
public void Anyname
which means that you type public void and then a name that you make up on your own. Words that you need to replace with your own words are set in italicized computerese
.
What You Dont Have to Read
Pick the first chapter or section that has material you dont already know and start reading there. Of course, you may hate making decisions as much as I do. If so, here are some guidelines you can follow:
If you already know what kind of an animal Java is and you dont care what happens behind the scenes when an Android app runs: Skip . Believe me I wont mind.