Supplemental files and examples for this book can be found at http://examples.oreilly.com/0636920016632/. Please use a standard desktop web browser to access these files, as they may not be accessible from all ereader devices.
All code files or examples referenced in the book will be available online. For physical books that ship with an accompanying disc, whenever possible, weve posted all CD/DVD content. Note that while we provide as much of the media content as we are able via free download, we are sometimes limited by licensing restrictions. Please direct any questions or concerns to .
Foreword
Our consumer culture gives us all sorts of opportunities for entertainment, pleasure and sometimes even learning. However, by and large, these are passive activities. Thats OKwe all like to kick back sometimes and be entertainedbut it shouldnt be the whole picture. In addition to the appeal of consuming, theres the satisfaction of producingthat is, of creating. Its the joy and pride that results when we draw a picture, build a model airplane, or bake some bread.
The high-tech objects (like cell phones, tablet computers, TVs, etc.) that we use today to consume entertainment and information are black boxes to most of us. Their workings are incomprehensible and, while there are capabilities in some of them that enable the user to draw pictures, make videos, etc., they are not, in and of themselves, creative media. In other words, most people cant create the apps that run on these gadgets.
What if we could change that? What if we could take creative control of our everyday gadgets, like cell phones? What if building an app for your cell phone was as easy as drawing a picture or baking a loaf of bread? What if we could close the gap between the objects of our consumer culture and the media of our creative lives?
For one, it could demystify those objects. Rather than being black boxes, impenetrable to our sight, they become objects that can be tinkered with. They become objects capable of our understanding. We gain a less passive and more creative relationship to them, and we get to play with these devices in a much deeper, more significant way when we can actually build things for them.
When Hal Abelson first spoke to me about the idea that became App Inventor, we talked about the unique motivating force that cell phones could have in education. He wondered if we could use that motivating force to help introduce students to concepts in computer science. As we built it and tried it in classes like Dave Wolbers, we started to realize that something even more powerful was happening: App Inventor was starting to turn students from consumers to creators. Students thought it was fun and exhilarating to build apps for their phones! When one of Daves students built the simple but powerful No Texting While Driving app, we really started to imagine what would happen if anybody, not just professional software engineers, could build an app.
So we worked hard to make App Inventor easier and more fun to use. Weve worked to make it more powerful (but still simple) as well. And were continuing this workApp Inventor is still a beta product and we have exciting plans for it.
The authors of this book are truly world-class educators and software engineers. Id like to personally thank them for their work in building, testing, and documenting the App Inventor for Android product and, of course, for writing this wonderful book.
Now go, unleash your creativity and build an app!
Mark Friedman
Tech Lead and Manager of the App Inventor for Android project, Google
Preface
Youre on your regular running route, just jogging along, and an idea for the next killer mobile app hits you. All the way home, you dont even care what your time is, all you can think about is getting your idea out there. But how exactly do you do that? Youre no programmer, and that would take years, and time is money, and...well, someone has probably done it already anyway. Just like that, your idea is dead in the water.
Now imagine a different world, where creating apps doesnt require years of programming experience, where artists, scientists, humanitarians, health-care workers, attorneys, firefighters, marathon runners, football coaches, and people from all walks of life can create apps. Imagine a world where you can transform ideas into prototypes without hiring programmers, where you can make apps that work specifically for you, where you can adapt mobile computing to fit your personal needs.
This is the world of App Inventor, Googles new visual programming tool for building mobile apps. Based on a visual blocks programming method thats proven successful even with kids, App Inventor dramatically lowers the barriers to creating apps for Android phones and devices. How about a video game where the characters look like you and your friends? Or a did you pick up the milk? app that reminds you if its after 3 p.m. and youre near the grocery store? Or a quiz app you give your significant other thats in fact a surprise marriage proposal? Question 4: Will you marry me? Press the button to accept by sending a text message. Someone really created an App Inventor app to propose marriage like this, and she said yes!
A Blocks Language for Mobile Phones
App Inventor is a visual, drag-and-drop tool for building mobile apps on the Android platform. You design the user interface (the visual appearance) of an app using a web-based graphical user interface (GUI) builder, then you specify the apps behavior by piecing together blocks as if you were working on a puzzle.
shows the blocks for an early version of an app created by Daniel Finnegan, a university student who had never programmed before. Can you tell what the app does?
Figure 1. App Inventor blocks specify the functionality of your app
The app is a text answering machine. You launch it when youre driving and it autoresponds to the texts you receive.
Because the blocks are more understandable than traditional programming code, youre immediately drawn in, and the real-world utility gets you asking questions like: Can I make it so the received texts are spoken aloud? Can I make it so the response sent back could be customized? Can I write an app that lets people vote for something by text, like on American Idol? The answer to all these questions is yes, and in this book, well show you how.