Android Apps for Absolute Beginners
Total Page:16
File Type:pdf, Size:1020Kb
Android Apps for Absolute Beginners ■ ■ ■ Wallace Jackson i Android Apps For Absolute Beginners Copyright © 2011 by Wallace Jackson All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN 978-1-4302-3446-3 ISBN 978-1-4302-3447-0 (eBook) Printed and bound in the United States of America (POD) Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. President and Publisher: Paul Manning Lead Editor: Matthew Moodie Technical Reviewer: Kunal Mittal Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Jeff Olson, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Corbin Collins Copy Editors: Marilyn Smith, Sharon Terdeman, Tracy Brown Compositor: MacPS, LLC Indexer: BIM Indexing & Proofreading Services Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. For information on translations, please e-mail [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at www.apress.com. You will need to answer questions pertaining to this book in order to successfully download the code. In loving memory of all of our wonderful furry companions who graced our lives with unconditional love for decades here on our ranch in the La Purisima State Historic Park on the Point Conception Peninsula in Northern Santa Barbara County. Contents at a Glance Contents .............................................................................................................. v About the Author ................................................................................................. x About the Technical Reviewer ........................................................................... xi Acknowledgments ............................................................................................ xii Introduction ..................................................................................................... xiii ■Chapter 1: Preliminary Information: Before We Get Started ........................... 1 ■Chapter 2: What’s Next? Our Road Ahead ..................................................... 11 ■Chapter 3: Setting Up Your Android Development Environment ................... 19 ■Chapter 4: Introducing the Android Software Development Platform ........... 41 ■Chapter 5: Android Framework Overview ..................................................... 67 ■Chapter 6: Screen Layout Design: Views and Layouts .................................. 89 ■Chapter 7: UI Design: Buttons, Menus, and Dialogs .................................... 115 ■Chapter 8: An Introduction to Graphics Resources in Android ................... 147 ■Chapter 9: Adding Interactivity: Handling UI Events ................................... 183 ■Chapter 10: Understanding Content Providers ............................................ 217 ■Chapter 11: Understanding Intents and Intent Filters ................................. 255 ■Chapter 12: The Future ................................................................................ 297 Index ............................................................................................................... 311 iv Contents Contents at a Glance .......................................................................................... iv About the Author ................................................................................................. x About the Technical Reviewer ........................................................................... xi Acknowledgments ............................................................................................ xii Introduction ..................................................................................................... xiii ■Chapter 1: Preliminary Information: Before We Get Started ........................... 1 Some History: What Is Android? ............................................................................................................................. 2 Advantage Android: How Can Android Benefit Me? ................................................................................................ 3 The Scope of This Book .......................................................................................................................................... 4 What’s Covered .................................................................................................................................................. 4 What’s Not Covered ........................................................................................................................................... 5 Preparing for Liftoff: SDK Tools to Download ......................................................................................................... 5 Java ................................................................................................................................................................... 6 Eclipse ............................................................................................................................................................... 7 Android SDK ....................................................................................................................................................... 8 Summary ................................................................................................................................................................ 8 ■Chapter 2: What’s Next? Our Road Ahead ..................................................... 11 Your Android Development IDE ............................................................................................................................. 11 Java, XML, and How Android Works ..................................................................................................................... 13 The Android Application Framework ..................................................................................................................... 14 Screen Layout Design ........................................................................................................................................... 14 User Interface Design ........................................................................................................................................... 15 Graphics and Animation Design ............................................................................................................................ 15 Interactivity ........................................................................................................................................................... 16 Content Providers ................................................................................................................................................. 16 Intents and Intent Filters ....................................................................................................................................... 17 The Future of Android ........................................................................................................................................... 17 Summary .............................................................................................................................................................. 18 ■Chapter 3: Setting Up Your Android Development Environment ................... 19 Installing Java, Eclipse, and Android .................................................................................................................... 19 Java SE and JRE: Your Foundation for Application Development .................................................................... 20 v ■ CONTENTS Eclipse IDE: The Development Environment ...................................................................................................