App Inventor 2
Article Index
App Inventor 2
Chapters 8 - 17
Chapters 18 - 24, Conclusion

 

Chapter 8 Presidents Quiz

This app is a quiz that asks questions about American presidents, but it can be adapted for any subject. The app uses lists to store the questions and their corresponding answers, and if/else components to determine if the answer is correct. Pictures of the relevant president are also shown. Index variables are used to map the correct answer to the question.

I can imagine this being a very useful app for teachers and students, and it can easily be extended to cover other topics. The app is relatively static, with the questions and answers being hardcoded, in chapter 10 a dynamic quiz is created i.e. you enter the questions to ask together with their answers.

 

Chapter 9 Xylophone 

This app presents a xylophone on the screen which plays a different note for each bar touched. Additionally, there is a button that allows you to replay the notes you played earlier.

The chapter has a useful section on when you should decide to create a procedure (i.e. when you have repeated/similar code), and there’s some advanced use of lists (adding items, getting data, removing items). The bars of the xylophone are created using buttons, the click event of each button plays the relevant sound file.

 

Chapter 10 MakeQuiz and TakeQuiz

This chapter is really an extension of chapter 8’s Presidents Quiz, but it is dynamic rather than static in nature. It builds two apps, the first (MakeQuiz) creates the quiz dynamically, where you enter questions together with their answers, and the second app (TakeQuiz) allows you to take the quiz.

The questions and answers are saved to a central server using the TinyWebDB component, this central database is the input source to the TakeQuiz app, allowing users in different locations to take the test. The app, uses the “for each” block to process collections of data.

This app should prove very useful for teachers and their students. Additionally, the concept of using a centralised database to feed client apps should give you ideas for creating your own apps.

 

Chapter 11 Broadcast Hub

This app allows users to subscribe to a service, and get messages whenever the other service users post updates. It was originally designed for mobiles in remote areas, that didn’t have internet access. The underlying design might prove useful in creating other non-internet connected apps.

The app inspects incoming text messages to determine if the user is requesting a subscription – it will add them, additionally if any message is from a subscriber, it distributes the message to other subscribers. Subscriber details are persisted using the TinyDB component.

Figure 11.1 is too small to read, and some code in this chapter is too small to read easily. Figure 11.11 has the complete code for the app, however, ideally all code that is related should be grouped together, making it easier to understand what the app does.

 

Chapter 12 Robot Remote

This chapter builds an app that allows you to control a LEGO MINDSTORMS NXT robot. The app uses the Bluetooth component to connect to the robot, the NxtDrive component controls the robot’s movement (drive, turn, stop), and the NxtUltrasonicSensor component allows the robot to sense obstructions. The Notifier component is used to display any error messages.

This chapter illustrates the abstract nature of the App Inventor code, allowing a few blocks to remotely control a robot. If you’re into robotics, this should prove a very useful chapter.

 

AppInventor2

 

Chapter 13 Amazon at the Bookstore

This app allows you to interact with Amazon’s API (web service) to get details about a book via its ISBN code - which can be entered manually or scanned via a barcode scanner. The TinyWebDB component is used to link to Amazon’s API. The returned data is formatted, to present it in a more meaningful manner.

Since using the web can be slow, there’s a useful point about informing your users about what is happening (e.g. “Searching Amazon...” label). There’s a helpful idea about creating your own web service API using Python together with Google’s App Engine - various links are provided for further information. Unfortunately, some of the chapter’s images are too small to read easily.

Up until now, each chapter has built a specific app, highlighting the capabilities of App Inventor. Now the approach changes, having learned the practical aspects of creating apps, the second half of the book puts what has been learned into a more theoretical/reference/programming context. The practical chapters and apps are referenced throughout. In many ways, you can develop your own apps using what you’ve already learned in the practical chapters, however to get the most out of development, you should understand the approaches and advice given in the rest of the book.

 

Chapter 14 Understanding an App’s Architecture

This chapter provides a high level overview of an app’s structure from a developer’s viewpoint. Components can be broken down into those that are visible and non-visible, and their behaviours broken down into events and the event response. The various event types are briefly described, namely: user-initiated, initialization, timer, animation, and external events. The events can repeat, branch, run a sequence of commands, and interact with databases and the web.

This chapter shows how to view an app from a developer’s perspective rather than the more typical user’s viewpoint.

 

Chapter 15 Engineering and Debugging an App

As app complexity increases, so does need for planning. The tried and tested software engineering principles and debugging techniques discussed here should save you time and frustration.

Software engineering principles discussed include: get users involved early (it’s easy to build for the wrong problem), build a prototype and increment it, code/test in small increments (agile development), design the logic before you code, and use comments for others and yourself later.

Debugging techniques discussed include: manually walkthrough the blocks processing to understand it, watch variables (feature removed, maybe added back again later), create block of labels that show the current value of variables, test individual blocks (Do It option), enable/disable blocks.

This chapter has very sensible advice, taken from the field of software development. As an experienced developer I know that you can accept and follow the advice, or you can ignore it and learn the hard way - either way you’ll eventually follow it . When discussing the concepts, useful references are made to the apps created in the tutorial section of the book.

 

Chapter 16 Programming Your App’s Memory

This short chapter discusses storing information in variables or a component’s property settings for later usage. The book describes properties and variable as ‘named memory slots’. The chapter shows how to define/get/set variables, increment variables, and how they’re used in IF tests.

 

Chapter 17 Creating Animated Apps

This chapter describes the various methods of creating apps with objects that move. Movement itself is an illusion, being a succession of images in different but nearby places. The Ball and ImageSprite use the speed and heading settings within the canvas components to move, the clock timer can also move images by using an object’s MoveTo function.

Timer events are executed according to the timer interval, and can move objects via their MoveTo function. Speed depends on TimerInterval frequency and parameters of the MoveTo function. Collision detection determines what to do when objects collide (e.g. vibrate, play sound, replace image). The EdgeReached event determines what to do when an edge is reached. The CollidedWith and NoLongerCollidedWith (e.g. ball leaves bat) events determine what happens when components collide. The chapter also shows it is possible to perform interactive animation e.g. user clicks a button to enable/disable timer.



Last Updated ( Sunday, 04 January 2015 )