App Inventor 2 |
Page 1 of 3 Authors: David Wolber, Hal Abelson, Ellen Spertus and Liz Looney Publisher: O'Reilly Do you want to create a mobile app? Or want a gentle introduction to programming? This book aims to help you with both. A recent leader article in The Economist’s “The World in 2015” magazine says there are currently 2.8 billion Smartphone users in the world, this is expected to rise to 4.5 billion by the end of 2016. Additionally, the market intelligence firm IDC says 85% of phones sold in Q2 2014 (latest figures) use the Android operating system. These figures suggest creating Android mobile apps is potentially very lucrative. This book assumes no previous programming experience, nor a technology background. It aims to provide an easy introduction to Android mobile development specifically, and programming in general. The App Inventor environment takes a visual approach to programming, creating apps can be as simple as drag-and-drop components onto the screen area and setting their properties. All work is stored in the cloud, so there are no installation or update problems to contend with. App Inventor was originally created by Google, and then passed to MIT to develop and support. Below is a chapter-by-chapter exploration of the topics covered.
Chapter 1 HelloPurr The aim of this chapter is twofold, the first is to introduce the App Inventor environment, and the second is to create a simple app. The HelloPurr app presents an image of a cat, which purrs when stroked, and meows when the phone is shaken. The chapter opens with a look at the App Inventor environment, which involves browsing to http://ai2.appinventor.mit.edu/, where you create a new project. App Inventor is a cloud based tool, with all the work/files stored remotely. The chapter provides a step-by-step walkthrough of the HelloPurr app, this involves: adding a button to the screen, changing its size, adding an image of a cat to it, adding a sound file (for the cat’s meow sound) and linking it to the cat’s image. All coding is done visually via drag-and-drop of components and changing their properties. The chapter continues by showing you how to test your app, via your phone, or an emulator. Continuous testing as development proceeds is strongly encouraged. Lastly, the app is packaged so that it can be downloaded to a phone, as a stand-alone app. Various suggestions for extending the app are given, together with a helpful chapter summary (as they are throughout the book). This chapter provides a gentle introduction to the App Inventor environment, creating, testing and deploying your first app. Useful step-by-step guidance, helpful diagrams and code blocks, and discussions are provided (as they are throughout the book), all make the app creation process easy to understand and follow. I may be overly critical of this chapter, but in many ways, this is the most important chapter of the book. A key factor in creating an app is understanding the App Inventor environment, get this right and everyone is happy, get it wrong and it can lead to frustration and abandonment! While the book covers most of the steps, there is no mention of having to log into the App Inventor site via a Google account - this should have been included. Useful screenshots should have been provided in the section “Downloading the App to Your Android Device”, rather than rely on just the text. These additions only need to be shown once, and can be referenced throughout the book.
Chapter 2 PaintPot The PaintPot app lets you draw on the screen with your finger, using different colours, over an image that you can replace with one taken on your phone’s camera. The app introduces the canvas object (for drawing on), the arrangement object (for layout), and variables for storing values. The components are added to the screen, and event handlers (blocks) linked in, finally properties are set. The canvas has a touched property, which is helpful for drawing on the screen. The use of parameters in the canvas’s touched event handler is explained. Code is given to take a photo with the phone’s camera and draw in different colours, over the image of a person’s face. This is a fun app, since most people will enjoy drawing over photos. There’s a small error in the complete app code, the code relating to SmallButton.Click and BigButton.Click is wrong, but it is correct in the body of the text.
Chapter 3 MoleMash The MoleMash app is a game, where a mole appears randomly and briefly on the screen, and you have to touch it, the game records the number of hits and misses. This chapter introduces you to the canvas object, touch-sensitive moving images, timer events (to move the image), random numbers (to set the random location of the mole image), abstract procedures and, of course, a fun game!
Chapter 4 No Texting While Driving This useful app is designed to be run when you are driving, if you receive a text message, the app will reply saying you can’t answer at the moment, it can even supply details of where you are currently. It is possible to amend the automatic response text, and also read aloud any messages received. The chapter introduces you to the TinyDB database component, which allows you to store data (useful if you change the automatic message text response). The TextToSpeech component is used to speak aloud the text message received. The LocationSensor component reports on the current location (address, latitude/longitude). The chapter also shows how to use comments to document code. There is an emphasis on piecemeal development and testing (and throughout the book too). This chapter starts to show the power of App Inventor, with this very useful app. It was created by an English major, showing you don’t need a deep technological background to create helpful apps.
Chapter 5 Ladybug Chase The Ladybug Chase is another game, where you tilt the screen to move the ladybug, enabling it to capture and eat aphids, whilst avoiding a frog, and watching your energy level! The chapter shows how to handle the collision of images (i.e. ladybug, aphid, frog), drawing on the screen (showing the changing energy supply), have multiple timer events (to move the ladybug and frog), keeping track of the energy level, and using procedures with parameters. This is another fun app, which could form the basis of your own game apps. Figure 5-19 showing the code for the complete app, is too small to read easily.
Chapter 6 Paris Tour Map This app is a tour guide for a trip to Paris, where you can select a predefined Parisian landmark (e.g. the Eiffel Tower) from a list, and the app will show its location on a map. Two versions of the app are created, the first uses the ActivityStart component and the second uses the WebViewer component. The ActivityStart component can be used to launch any Android app that is on your phone, however you have little control once it is launched. Whereas the WebViewer component displays the web pages within your app, here you have much more control. Both apps call the Google maps web site with parameters that indicate the site of interest (which is selected from the drop down list). There’s a good point made about the case-sensitive nature of the ActivityStart property values. The completed code for both examples is quite concise, indicating how much work App Inventor does.
Chapter 7 Android, Where’s My Car? This app records where you have parked your car, and then gives you directions to that location. The app uses the LocationSensor component to record where the car has been parked (address, latitude, longitude), these detailed are saved into a database via the TinyDB component. Google maps is used to locate your car’s position, and supply directions, from your current location. This is another very useful app, which can easily be extended for other location-related problems. |
||||
Last Updated ( Sunday, 04 January 2015 ) |