+ All Categories
Home > Documents > 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android:...

001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android:...

Date post: 19-Jul-2020
Category:
Upload: others
View: 22 times
Download: 0 times
Share this document with a friend
30
Transcript
Page 1: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,
Page 2: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

01_9781119991335-ffirs.indd v01_9781119991335-ffirs.indd v 3/28/11 12:44 PM3/28/11 12:44 PM

Page 3: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

App Inventor for Android:Build Your Own Apps — No Experience Required!

01_9781119991335-ffirs.indd i01_9781119991335-ffirs.indd i 3/28/11 12:44 PM3/28/11 12:44 PM

Page 4: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

01_9781119991335-ffirs.indd ii01_9781119991335-ffirs.indd ii 3/28/11 12:44 PM3/28/11 12:44 PM

Page 5: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

App Inventor for Android:Build Your Own Apps — No Experience Required!

Jason Tyler

A John Wiley and Sons, Ltd, Publication

01_9781119991335-ffirs.indd iii01_9781119991335-ffirs.indd iii 3/28/11 12:44 PM3/28/11 12:44 PM

Page 6: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

App Inventor for Android: Build Your Own Apps — No Experience Required!

Th is edition fi rst published 2011

© 2011 John Wiley & Sons, Ltd

Registered offi ce

John Wiley & Sons Ltd, Th e Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom

For details of our global editorial offi ces, for customer services and for information about how to apply for permission to reuse the copyright material in this book, please see our Web site at www.wiley.com.

Th e right of the author to be identifi ed as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988.

All rights reserved. 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 or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher.

GOOGLE is a trademark of Google Inc.

Th e Android Robot is created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License located at http://creativecommons.org/licenses/by/3.0/.

Screenshots and images from App Inventor for Android are created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License located at http://creativecommons.org/licenses/by/3.0/.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.

DESIGNATIONS USED BY COMPANIES TO DISTINGUISH THEIR PRODUCTS ARE OFTEN CLAIMED AS TRADEMARKS. ALL BRAND NAMES AND PRODUCT NAMES USED IN THIS BOOK ARE TRADE NAMES, SERVICE MARKS, TRADEMARKS OR REGISTERED TRADEMARKS OF THEIR RESPECTIVE OWNERS. THE PUBLISHER IS NOT ASSOCIATED WITH ANY PRODUCT OR VENDOR MENTIONED IN THIS BOOK. THIS PUBLICATION IS DESIGNED TO PROVIDE ACCURATE AND AUTHORITATIVE INFORMATION IN REGARD TO THE SUBJECT MATTER COVERED. IT IS SOLD ON THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING PROFESSIONAL SERVICES. IF PROFESSIONAL ADVICE OR OTHER EXPERT ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL SHOULD BE SOUGHT.

978-1-119-99133-5

A catalogue record for this book is available from the British Library.

Set in 10/14 Chaparral by Andrea Hornberger

Printed in the United States of America by C J Krehbiel

01_9781119991335-ffirs.indd iv01_9781119991335-ffirs.indd iv 3/28/11 12:44 PM3/28/11 12:44 PM

Page 7: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

About the AuthorJASON TYLER is passionate about technology and people. Jason teaches technology pro-fessionally to help people achieve their goals using the power of technology. He plays with technology because he loves the empowerment that technology can bring, and also because he is attracted to anything shiny.

Jason is a lifetime student who considers a day wasted if he is not awed by something. His passion for technology has lead him to hold multiple certifi cations from Microsoft, Cisco, CompTIA, and ITIL. His passion for people led him to seek a B. A. in theology.

Jason is an avid and dedicated photographer, sailor, and gamer. Of all the things he is, Jason is proudest to be the husband of Rebecca and the father of Liam and Declan.

01_9781119991335-ffirs.indd v01_9781119991335-ffirs.indd v 3/28/11 12:44 PM3/28/11 12:44 PM

Page 8: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

Some of the people who helped bring this book to market include the following:

Credits

Editorial and ProductionVP Consumer and Technology Publishing Director: Michelle LeeteAssociate Director- Book Content Management: Martin TribeAssociate Publisher: Chris WebbPublishing Assistant: Ellie ScottDevelopment Editor: Linda MorrisTechnical Editor: Liam Green-HughesCopy Editor: Linda MorrisEditorial Manager: Jodi JensenSenior Project Editor: Sara ShlaerEditorial Assistant: Leslie Saxman

Marketing:Senior Marketing Manager: Louise BreinholtMarketing Executive: Kate Parrett

Composition Services:Compositors: Andrea Hornberger, Jennifer MayberryProof Reader: Susan HobbsIndexer: Ty Koontz

01_9781119991335-ffirs.indd vi01_9781119991335-ffirs.indd vi 3/28/11 12:44 PM3/28/11 12:44 PM

Page 9: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

To Rebecca Sue. Th is is one of the high places I promised you. Th ank you for being there in the low places, too.

01_9781119991335-ffirs.indd vii01_9781119991335-ffirs.indd vii 3/28/11 12:44 PM3/28/11 12:44 PM

Page 10: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

Author’s AcknowledgmentsRebecca, thank you for the sacrifi ces you made to make this book possible. I love you. Forever.

Liam and Declan, thank you for letting daddy write so much.

Jon Bartolomeo, your honesty and grounded technical knowledge were invaluable.

Bill Dwyer, thanks for the programming review and teaching. You are an amazing teacher.

Hal Abelson, thank you so much for App Inventor and the years of dedication to the ethos behind it. You have become one of the giants.

Th e App Inventor Google Developer team: Karen, Sharon, Liz, and Mark. Th ere are not enough superlatives to describe your contribution to leveling the Android application play-ing fi eld. Your enthusiasm, dedication, and downright rockstar-ness are unparalleled.

Th e AI PowerUsers: Sua Th ov, Ed, Josh Turner, Shival, and Steve. I have grown and learned working with you guys.

Rachael, you are the best boss to let me work on this so much.

Chris Webb, I will be eternally grateful to you for giving me this opportunity and putting up with my author jitters.

Linda, thank you so much for making me look good.

Dennis Cohen, thanks for helping out with the Mac parts.

Dad, thanks for getting me started in technology.

Mom, thanks for educating me and making me love books, words, and excellence. I owe you the most.

Finally, thanks to the rainy days that got me through all of the hard bits.

01_9781119991335-ffirs.indd viii01_9781119991335-ffirs.indd viii 3/28/11 12:44 PM3/28/11 12:44 PM

Page 11: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

Contents

About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vCredits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .viAuthor’s Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  1Who Th is Book Is For . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Part I: Getting Up and Running with Google App Inventor . . . . . . . . . . . . . . . . . . . . . . . . . 3Part II: Designing Your Own Apps: Step-by-Step Guides . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Part III: Reference and Appendixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Downloadable Project Files and Bonus Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4About Th is Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Part ICHAPTER 1Building Your First App While Exploring the Interface  . . . . . . . . . . .  7

Starting a New Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Getting Familiar with Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Th e Palette column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Th e Viewer column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Th e Components column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Media column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Th e Properties column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Adding Components to Your New Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Adding a Button component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Adding a Label component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17Adding an Image component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17Adding a Sound component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Renaming the Screen component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20Renaming the Image component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Renaming the Label component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Renaming the Button component. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Renaming the Sound component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Adding sound for the Sound component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Adding images for the Image component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

02_9781119991335-ftoc.indd ix02_9781119991335-ftoc.indd ix 3/28/11 12:44 PM3/28/11 12:44 PM

Page 12: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

x A P P I N V E N T O R F O R A N D R O I D 

Understanding properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Setting Image component properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Setting Label component properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Setting Button component properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Setting Sound component properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Introducing the Blocks Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28Previewing Built-in Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Placing Your Button Component Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31Placing Your Sound Component Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

Putting the fi nal touches on your project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32Saving your new application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32Th e Save As button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Th e Checkpoint button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Packaging your app . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Using the Show Barcode option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Using the Download to Th is Computer option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Using the Download to Connected Phone option . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Managing Your Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Downloading your project source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37Uploading your project source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38Deleting a project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Loading an existing project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

CHAPTER 2Programming and Design Fundamentals . . . . . . . . . . . . . . . . . . . . .  41

Clarifying Your Design Idea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Getting Primitive with Your Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46Starting Easy, Getting More Complex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Mastering the Fundamentals of Programming Terminology . . . . . . . . . . . . . . . . . . . . . . . 51

Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

02_9781119991335-ftoc.indd x02_9781119991335-ftoc.indd x 3/28/11 12:44 PM3/28/11 12:44 PM

Page 13: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

xiT A B L E O F C O N T E N T S

Part IICHAPTER 3SounDroid: Creating an Android Sound Machine . . . . . . . . . . . . . . .  61

Creating SounDroid 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64New blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

Getting Started on SounDroid 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Adding components for the sound loop mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . 70Enabling more control over sound looping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

Expanding the SounDroid Project: SounDroid 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83Design goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85New blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

Getting Started on SounDroid 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86Building the logic for the timer counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88Defi ning the stop and start timer procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92Adding the procTimer procedure to the button event handlers . . . . . . . . . . . . . . . . . . 95

CHAPTER 4OrderDroid: A Maintainable Mobile Commerce App  . . . . . . . . . . . .  97

Creating the OrderDroid Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100New blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101

Getting Started on OrderDroid 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101Adding New Components to OrderDroid 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105

Gathering your form data to be e-mailed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111Creating an e-mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118

02_9781119991335-ftoc.indd xi02_9781119991335-ftoc.indd xi 3/28/11 12:44 PM3/28/11 12:44 PM

Page 14: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

xii A P P I N V E N T O R F O R A N D R O I D 

Creating OrderDroid 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125New blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126

Getting Started on OrderDroid 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126Adding navigational elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127Storing multiple items and formatting them for display . . . . . . . . . . . . . . . . . . . . . . .131Building the display procedure for the varShoppingCart list . . . . . . . . . . . . . . . . . . .134Updating the shopping cart display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136Finishing the shopping cart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137Th e e-mail procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138

CHAPTER 5AndroidDown: A Location-Aware Panic Button . . . . . . . . . . . . . . .  145

Creating the AndroidDown Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149

Getting Started on AndroidDown 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149Refi ning the interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .152Locating the user’s position with LocationSensor . . . . . . . . . . . . . . . . . . . . . . . . . . . .154Finalizing the location and phone number functionality . . . . . . . . . . . . . . . . . . . . . .159

Creating AndroidDown 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169New blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169

Getting Started on AndroidDown 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170Building your button event handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172Creating your button events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177Sending the message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180Finalizing the procLocationWait procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188

02_9781119991335-ftoc.indd xii02_9781119991335-ftoc.indd xii 3/28/11 12:44 PM3/28/11 12:44 PM

Page 15: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

xiiiT A B L E O F C O N T E N T S

CHAPTER 6AlphaDroid: An Alphabet Tracing Game  . . . . . . . . . . . . . . . . . . .  191

Creating AlphaDroid 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .193Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .194New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .194New blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .194

Getting Started on AlphaDroid 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .194Picking colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .196Understanding dragging and touching events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .200Changing the BackgroundImage property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202Further refi ning the Canvas1.Touched event handler . . . . . . . . . . . . . . . . . . . . . . . . .203Setting up button event handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205Putting the fi nishing touches on the drawing functionality . . . . . . . . . . . . . . . . . . . .206

Creating AlphaDroid 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .212

Beginning AlphaDroid 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .212Making Andy move . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215Managing the sprite at the edge of the canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .217Handling sprite touch events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .218

CHAPTER 7PunchDroid: An Android Punch Bug Game  . . . . . . . . . . . . . . . . .  225

Creating the PunchDroid Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .227Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .227Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .228

Getting Started on the PunchDroid Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .228Handling the Settings page events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .233Handling events on the main play screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246

Installing the PunchDroid Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257

02_9781119991335-ftoc.indd xiii02_9781119991335-ftoc.indd xiii 3/28/11 12:44 PM3/28/11 12:44 PM

Page 16: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

xiv A P P I N V E N T O R F O R A N D R O I D 

CHAPTER 8Collection Assistant: A Barcode and Database Application  . . . . . . .  259

Creating Collection Assistant 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .261Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262New blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262

Getting Started on Collection Assistant 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .263Creating Collection Assistant 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279

Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280New blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280

Getting Started on Collection Assistant 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281Challenging Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .298

CHAPTER 9BlueChat: A Bluetooth Chat Client  . . . . . . . . . . . . . . . . . . . . . . .  299

Creating the BlueChat Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .300Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .300Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .302New blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .302Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .302

Getting Started on BlueChat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .303Challenging Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323

CHAPTER 10TwiTorial: A Twitter Application . . . . . . . . . . . . . . . . . . . . . . . . .  325

Creating the TwiTorial Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .326Your design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .326Your primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .327New components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .327New blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .328Your progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .328

Getting Started on TwiTorial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .329

02_9781119991335-ftoc.indd xiv02_9781119991335-ftoc.indd xiv 3/28/11 12:44 PM3/28/11 12:44 PM

Page 17: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

xvT A B L E O F C O N T E N T S

Part IIIBlocks and Component Reference . . . . . . . . . . . . . . . . . . . . . . . .  361

Built-In Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362Th e Defi nitions drawer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362

ProcedureWithResult . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .364Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .365Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .366

| . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .366Th e Text drawer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .367

Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .367Equals (=) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .367Join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .368Text Less Th an (<), Text Greater Th an (>), and Text Equals (=) . . . . . . . . . . . . . .368Trim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .369Upcase and Downcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .369Starts at . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .370Contains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .370Split at First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .370Split at First of Any . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .370Split at Any . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .372Split . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .372Split at Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .373

Th e Math drawer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .373Random Integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .373Random Fraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .373

Th e Control drawer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .373While . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .374Close-Screen-with-Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .374Get Start Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .374For Range. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .374

My Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .374My Defi nitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .375

Component blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .375Basic palette components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .375PasswordTextBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .376

02_9781119991335-ftoc.indd xv02_9781119991335-ftoc.indd xv 3/28/11 12:44 PM3/28/11 12:44 PM

Page 18: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

xvi A P P I N V E N T O R F O R A N D R O I D 

Media palette components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .377Camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .377ImagePicker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .378VideoPlayer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .378

Th e Social palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .379ContactPicker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .379EmailPicker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .379PhoneCall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .380PhoneNumberPicker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .381

Th e Sensors palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .381AccelerometerSensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .381Orientation Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .382

Th e Lego Mindstorms palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385Th e Other Stuff palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .386

SpeechRecognizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .386TextToSpeech . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .386

Not Ready for Prime Time Palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .388GameClient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .388SoundRecorder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .388

APPENDIX ASetting Up Your Phone and Computer . . . . . . . . . . . . . . . . . . . . .  391

Setting Up Your Phone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .392Installing Java on Your Computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .395

Chrome . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .397Mozilla Firefox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .397Internet Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .398

Testing Java Web Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .398Testing your Java Web Start behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .399

Chrome . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .400Firefox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .401Safari . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .402Internet Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .403

Troubleshooting your Java installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .403Installing the App Inventor Extras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .404

02_9781119991335-ftoc.indd xvi02_9781119991335-ftoc.indd xvi 3/28/11 12:44 PM3/28/11 12:44 PM

Page 19: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

xviiT A B L E O F C O N T E N T S

Working with ADB (Android Debug Bridge) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .405Opening a command prompt and navigating

to App Inventor Extras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .407Testing for device connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .408

Adapting to Special Circumstances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .409Using ADB to view the phone log in real-time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .409Capturing the phone log to a fi le for notepad/textedit viewing . . . . . . . . . . . . . . . . .410

Working with the Android Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .410Exploring the Android SDK and Other Emulator Options . . . . . . . . . . . . . . . . . . . . . . . .412Troubleshooting Your Phone’s Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .413

Verifying device driver installation for your phone . . . . . . . . . . . . . . . . . . . . . . . . . . .413Installing or reinstalling drivers for your phone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .415Uninstalling your device drivers in Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .415Manually installing custom drivers in Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416

APPENDIX BCreating Your Own TinyWebDB . . . . . . . . . . . . . . . . . . . . . . . . .  419

Setting Up Your Google App Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .421Customizing and Installing the TinyWebDB Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . .423

BONUS CHAPTERSprite Interaction: A Physics Primer . . . . . . . . . . . . . . On the Web Site

Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  427

02_9781119991335-ftoc.indd xvii02_9781119991335-ftoc.indd xvii 3/28/11 12:44 PM3/28/11 12:44 PM

Page 20: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

02_9781119991335-ftoc.indd xviii02_9781119991335-ftoc.indd xviii 3/28/11 12:44 PM3/28/11 12:44 PM

Page 21: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

Introduction

03_9781119991335-intro.indd 103_9781119991335-intro.indd 1 3/28/11 12:44 PM3/28/11 12:44 PM

Page 22: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

A P P I N V E N T O R F O R A N D R O I D2

WHEN ANDROID WAS fi rst introduced by Google and the Open Handset Alliance, my fi rst thought was of how awesome it would be to have a free open-source application environ-ment for the growing smart phone revolution. Th e harsh reality hit when I tried to apply my rusty programming skills to the Java and Android software development kit (SDK). Th e learning curve was too steep, with too few rewards to keep me going. Th en Google announced the amazing App Inventor, which makes it possible for anyone to build Android applications. I was excited and my hope for building my own applications was renewed. As I have learned, played with, and grown with App Inventor, I have been amazed at what non-experts (includ-ing me) can build with this tool. After having spent a few months with App Inventor, I have found my journey to traditional Java and SDK development much easier, more fun, and less frustrating.

Who This Book Is ForTh is book is for anyone from a complete computer newbie to an experienced designer and developer. It will help anyone familiarize themselves with the App Inventor interface and components.

Th e really exciting news is that the world of Android applications awaits you even if you have absolutely zero programming knowledge. If you have ever had a brilliant idea for an applica-tion, App Inventor can help that idea become a reality. If you have ever been curious about how phone applications are created and function, you can learn by creating applications yourself. App Inventor is also great for rapid prototyping applications for testing and display.

Th is book helps you create applications for your Android device using Google’s App Inventor for Android. App Inventor is a Web-based application that allows everyone from ordinary phone owners to experienced developers to create applications for Android.

App Inventor for Android: Build Your Own Apps — No Experience Required! is also great for designers or developers with great ideas and a solid background in development. App Inventor can allow very technical and experienced app developers to spend less time worry-ing about debugging, syntax, and development and more time making rock-star applications.

03_9781119991335-intro.indd 203_9781119991335-intro.indd 2 3/28/11 12:44 PM3/28/11 12:44 PM

Page 23: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

I N T R O D U C T I O N 3

Part I: Getting Up and Running with Google App InventorYou start with an exploration of the interface and a simple project application. In Part I, you become familiar with the interface and the basic components.

By immediately adding components and programming logic, any hesitation you may have about programming with App Inventor is eased. Each part of the App Inventor interface is explained. Th is allows you to move into the Part II with confi dence and comfort.

Part II: Designing Your Own Apps: Step-by-Step GuidesIn this part, you learn the basics of designing applications from a napkin sketch to a func-tioning application. I walk you through the process of creating various apps ranging from a child’s alphabet tracing game to a Bluetooth chat client, and more. Many of the applications contain concepts and programming that you can use in your own applications.

Part III: Reference and AppendixesTh is book also contains a Blocks and Component Reference that covers important blocks not covered in the project chapters. I explain blocks such as text blocks and demonstrate them graphically. You can use the examples to add functionality to your project or meet a specifi c design goal.

If you have not set up your phone to connect to the App Inventor application, you can fi nd information for setting up your computer and Android phone in Appendix A. Appendix B shows you all of the steps needed to set up your own TinyWebDB Service. Th e TinyWebDB service is used throughout the book as a Web database service. With a few minutes invest-ment, you create your own Web service for your applications to store and interchange data.

03_9781119991335-intro.indd 303_9781119991335-intro.indd 3 3/28/11 12:44 PM3/28/11 12:44 PM

Page 24: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

A P P I N V E N T O R F O R A N D R O I D4

Downloadable Project Files and Bonus ContentFor most of the projects, you need to download the project fi les and extract them to a loca-tion on your computer where you can fi nd them easily later. When you’re fi nished with each application, it will be fully functioning and can be loaded onto most Android devices. Th e project fi les can be downloaded from www.wiley.com/go/appinventorandroid.

Also on the Web site, you will fi nd a Bonus Chapter called "Sprite Interaction: A Physics Primer." Th is more advanced chapter appears on the Web as a downloadable .PDF viewable with Adobe Acrobat Reader.

About This BookTh is book follows a few typographical conventions for the sake of clarity. New terms appear in an italic font. URLs and special terms (such as block, event, or procedure names) appear in a monospaced font. Text you should type also appears in a monospaced font.

03_9781119991335-intro.indd 403_9781119991335-intro.indd 4 3/28/11 12:44 PM3/28/11 12:44 PM

Page 25: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

chapter 1 Building Your First App While Exploring the Interface

chapter 2 Programming and Design Fundamentals

Part I

04_9781119991335-pp01.indd 504_9781119991335-pp01.indd 5 3/28/11 12:44 PM3/28/11 12:44 PM

Page 26: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

In Part I, you stick your toe into the waters of App Inventor. Chapter 1

gets you started right away by walking you through the creation of a

simple app as a way to get familiar with the App Inventor user interface.

Chapter 2 is a primer on programming and design fundamentals. In that

chapter, I cover how to refine design goals, work with primitives, and

introduce you to must-know programming terminology.

If you are a more advanced App Inventor user, you may want to flip

right to Part II to get started building some more challenging apps.

04_9781119991335-pp01.indd 604_9781119991335-pp01.indd 6 3/28/11 12:44 PM3/28/11 12:44 PM

Page 27: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

chapter 1Bui lding Your First App While Exploring the Interface

in this chapter

❍ Becoming familiar with App Inventor’s interface

❍ Learning App Inventor–specifi c terminology

05_9781119991335-ch01.indd 705_9781119991335-ch01.indd 7 3/28/11 1:58 PM3/28/11 1:58 PM

Page 28: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

A P P I N V E N T O R F O R A N D R O I D8

APP INVENTOR IS an incredible new system from Google that allows Android applications to be designed and programmed with a Web page and Java interface. With very little pro-gramming knowledge, you can use App Inventor to create simple applications for yourself and your friends. With continuing experience with App Inventor, you can create very com-plex and powerful applications with App Inventor.

If you have ever had a fl ash of brilliance and thought, “Th ere should be an app for that!,” take heart. App Inventor makes it possible for you to create that app. If you don’t yet have that incredible and exciting idea for an application, building the projects in the following chapters is very likely to spark an idea for your own Android application. I recommend keeping a note-book nearby to jot down application ideas as you do each of the projects. Many applications that are built with App Inventor are person- or group-specifi c. Your church, civic group, or circle of friends could well benefi t from a common app that may exist but is not tailored for your group. Keep in mind that you don’t have to reinvent the wheel, but you can invent a nicer custom wheel with custom engraving and nice spinners.

If you have not signed up for an App Inventor account, you need to sign up at http://appinventor.googlelabs.com/. You need to have a Gmail or Google Apps account to sign up.

NOTE If you have not set up your computer and phone to work with App Inventor, turn to Appendix A and follow the steps to get set up for App Inventor programming.

Starting a New ProjectTo get started creating a project, start by logging into App Inventor with the account that you signed up with. If you have never logged in to App Inventor before, you see the About or Learn pages of the App Inventor Web site. Depending on whether you have logged in before and created a project, you may see the My Projects view or the Design view. If you are in the middle of building a project, App Inventor remembers the last loaded application and starts in Design view.

In this chapter and Chapter 2, you start your fi rst project, a simple soundboard that plays a single sound when the user taps a button on the user interface. I have chosen this as a start-ing project instead of a traditional “Hello, World” app because App Inventor is very untradi-tional. It lets you do so much more, so quickly.

05_9781119991335-ch01.indd 805_9781119991335-ch01.indd 8 3/28/11 1:58 PM3/28/11 1:58 PM

Page 29: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

C H A P T E R O N E B U I L D I N G Y O U R F I R S T A P P W H I L E E X P L O R I N G T H E I N T E R F A C E

9

To start a project from the My Projects view, follow these steps:

1. From the My Projects page (shown in Figure 1-1), click the New button. Th is brings up the New App Inventor for Android Project dialog box.

2. When prompted, type SounDroid (or any other name you like) in the Project Name fi eld. Keep the project name descriptive of what you are trying to do until you are com-pletely done with all the fl ashy awesomeness. At the end, you can use Save As from the Design view and give your app a cool marketing-oriented name like Appzilla, but for now, a catchy name like Appzilla won’t help you pick the app out of the crowd of apps and test projects you may soon have in your My Projects screen.

3. Click OK.

Figure -: Name your new project in the Project Name fi eld

Th e Design view screen loads with a blank project, as shown in Figure 1-2. Th is is where you start placing design elements and components for your app. I explore this view thoroughly in the “Getting Familiar with Design View” section later in this chapter.

05_9781119991335-ch01.indd 905_9781119991335-ch01.indd 9 3/28/11 1:59 PM3/28/11 1:59 PM

Page 30: 001 9781119991335-ffirs.indd v1 9781119991335-ffirs.indd v ...€¦ · App Inventor for Android: Build Your Own Apps — No Experience Required! Jason Tyler A John Wiley and Sons,

A P P I N V E N T O R F O R A N D R O I D10

Figure -: Th e Design view

for your new project

PropertiesComponentsPalettes

The Viewer Media

Th e blank rectangle in the center of the screen is known as the Viewer. It’s roughly analogous to the screen of your phone. You can see a notifi cation bar with battery, time, and network icons in it, just like your phone has. Still, you must remember that what you see in Design view is not what you will see on your phone. Th is is why you should start designing your application with your phone connected to your computer and App Inventor connected to your phone. You need to test your app on a real phone. Follow these steps to connect every-thing and get ready to test:

1. Connect your phone to a USB port on your computer. By connecting the phone to App Inventor and then returning to Design view, you can drop buttons, pictures, and text fi elds onto the blank canvas and see how they will look when the application is complete.

2. Open the Blocks Editor by clicking the Open the Blocks Editor button, as shown in Figure 1-3. Th is launches the Java Web start program that is the Blocks Editor. Your browser downloads a Java fi le and, hopefully, also starts it.

NOTE Java Web Start programs are applications that launch from your Web browser, but run as separate programs. The Blocks Editor is a part of App Inventor that runs separately from your browser. If you have trouble starting the Blocks Editor Java Web Start program, refer to Appendix A for set-up and troubleshooting help.

05_9781119991335-ch01.indd 1005_9781119991335-ch01.indd 10 3/28/11 1:59 PM3/28/11 1:59 PM


Recommended