Beginning PhoneGap is the book to teach you how to use PhoneGap to develop HTML5 Android apps.BEGINNING PHONEGAPNTRODUCTION.,,,,,,,,,,,,,,,,,,,,,,.,,,XiXCHAPTER 1 Introducing Phone GapCHAPTER 2 Installing and Configuring Phone GapCHAPTER 3 Basic WalkthroughCHAPTER 4 Events..45CHAPTER 5 Working with the Device, the Network, and Notifications59CHAPTER 6 Accelerometer73CHAPTER 7 Compass85CHAPTER8 Geolocation99CHAPTER 9 Media113CHAPTER 10 Camera....129CHAPTER 11 Storage∴....143CHAPTER 12 Files157CHAPTER 13 Contacts179CHAPTER 14 Capture..189CHAPTER 15 Creating a Note-Taking Application..........197APPENDIX A Answers to exercises....213APPENDIX B Tools for Phone Gap235APPENDIXc Phone Gap . js.247APPENDIXD Phone gap Plug-ins.,.,333INDEX,,,,,,,,,,,,349ffirs indd i10/27/115:04:55PMffirs indd ii10/27/115:04:56PMBEGINNINGPhone GapThomas myerWILEYJohn Wiley Sons, Incffirs indd10/27/115:04:56PMBeginning Phone GapPublished buhn Wiley Sons, Ir0475 Crosspoint boulevardIndianapolis, IN 46256www.wiley.conCopyright o 2012 by John Wiley Sons, InC, Indianapolis, IndianaPublished simultaneously in CanadaISBN:978-1-118-15665-0ISBN:978-1-11822600-1(ebk)ISBN:978-1-118-23932-2(cbk)SBN:978-1-118-25399-1(ebk)Manufactured in the United States of america10987654321No part of this publication may be reproduced stored in a retrieval system or transmitted in any form or by any meansclcctronic, mcchanical, photocopying, rccording, scanning or othcrwisc, except as permitted undcr Scctions 107 or 10of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorizationthrough payment of the appropriate per-copy fee to the copyright Clearance Center, 222 Rosewood Drive, DanversMAO1923, (978)750-8400, fax(978)646-8600 Rcqucsts to thc Publisher for permission should be addressed to thePermissions Department, John Wiley Sons, Inc, 111 River Street, Hoboken, NJ 07030,(201)748-601l, fax(201748-6008,oronlineathttp://www.wiley.com/go/permissicnsLimit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties withrespect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, includingwithout limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales orpromotional materials. The advice and strategies contained herein may not be suitable for every situation. This workis sold with thc undcrstanding that the publisher is not engaged in rendering legal, accounting, or other professionalservices. If professional assistance is required, the services of a competent professional person should be sought. Neitherthe publisher nor the author shall be liable for damages arising herefrom. the fact that an organization or Web site isreferred to in this work as a citation and/or a potential source of further information does not mean that the author or thepublisher endorses the information the organization or Web site may provide or recommendations it may make. Further,readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when thiswork was written and when it is readFor gencral information on our othcr products and scrviccs plcasc contact our Customer Carc Dcpartmcnt within theUnited States at( 877)762-2974, outside the United States at (317)572-3993 or fax (317)572-4002Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included withstandard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to mediasuch as a CD or dvd that is not included in the version you purchased, you may download this material athttp://booksupport.wiley.com.FormoreinformationaboutWileyproductsvisitwww.wiley.comLibrary of Congress Control Number: 2011939646Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress aretrademarks or registered trademarks of John Wiley Sons, Inc and/or its affiliates, in the United States and othercountries, and may not be used without written permission. Android is a trademark of google. black berry is a registeredtrademark of Research In Motion. all other trademarks are the property of their respective owners John Wiley sons,Inc, is not associated with any product or vendor mentioned in thffirs indd iv10/27/115:04:57PMo my wife, Hope, for loving me anyway.ffirs indd v10/27/115:04:58PMffirs indd vi10/27/115:04:58PMABOUT THE AUTHORTHOMAS MYER works and lives in Austin, Texas. He's been a php web developer for about tenyears, and a mobile apps developer for the past three. Until recently, he was the top dog of tripleDog Dare Media, but now works for Deal Management, LLC, out of Minnesota, where he buildsweb and mobile apps. You can follow him at @merman on twitter.ABOUT THE TECHNICAL EDITORSBRIAN LEROUX is the lead software architect at Nitobi inc. where he focuses on delivering web andpopular phone Gap Open Source framework, and is the creator of XUI and lawnchair or to themobile apps and helping developers all over the world write their apps. He is a contribDANNY LOWE was born in Huntington Beach, and raised in Southern california, but now callsAustin, Texas, his home. He is a computer programming superhero who has been skillfully hidingnis secret identity since 1996. When he is not writing code and saving the careers of projectmanagers by leaping tall deadlines in a single bound L owe is playing music, writing fictionand poetry, or hanging out with his wife, Stephanie, and two sons. Follow him on Twitter at@Danny InAustirffirs indd vi10/27/115:04:58PMffirs indd vii10/27/115:04:58PM