Post-HelloPurr-Answers

1. App Inventor has two main windows. What are they and what do they do?

The App Inventor programming environment has two windows: the component designer and the blocks editor. 

You use the component designer to define the user interface of the app as well as any non-visual components you need. User interface components include buttons, labels, image objects, and textboxes. Non-visual components include the Texting component, the Sound component, and the Text-To-Speech component.

You use the blocks editor to define the behavior of the app. An app's behavior is specified in terms of event-response handlers-- when an event occurs, what functions does the app perform in response.

2.  a. How do you test an app while you're developing it? 

You can plug a phone in to the computer during development and the app will appear on it. As you make changes in the component designer, the changes will occur on the phone. As you define behaviors in the blocks editor, you can immediately test them on the phone. This is called "live testing".

b. What if you wanted to use your app away from the computer, or make your app available to a friend. How do you do this?

If you get an app working with live testing, then unplug the phone, the app is not yet really deployed and you won't be able to use it. To deploy an app so that you can use it unplugged from the computer, you use the Package for Phone menu in the component designer. You can either have App Inventor display a barcode or generate a .apk file for the app. You can scan the barcode with a barcode scanner on your phone, and it will install. You can also copy the .apk file for use on the phone or the emulator.

c. What if you didn't have a phone, but wanted to program some apps. Could you? How?

You can develop apps and test them using the Android emulator. The emulator behaves like an Android device but runs on your computer.

3. The tutorials ask you to rename components in the Component Designer, different from their default names. Why is this important?

After you create the components for your app, you'll program their behavior in the blocks editor. When you open the blocks editor, there will be a palette drawer for each component containing event-handlers, functions, and properties for that component. It is important that you provide descriptive names in the component designer so you can easily identify the component, by name, in the blocks editor. 

One important style guideline is to have the component type as a suffix on each component name. So if you have a button in your app for making the kitty purr, you'll call it PurrButton.

4.  In an app Inventor app:

a. 
What is a component? 

A component is either a user interface object, e.g., button or textbox, or a non-visual component. Think of non-visual components as entities in the app that provide some functionality but aren't seen. The Texting and Sound components are prime examples.

b. What is a property?

A property is data associated with a component. Most visual components have properties like width, height, and background image which define how they look. You can conceptualize a property as a named memory cell holding a number or some text, something like you'd see in a spreadsheet. 

width

 200


c. What is an event?

An event is something that occurs while the app is running. Probably the most common event is the user clicking a button. Other events include a text being received by the phone, and the user dragging their finger across the screen.

App events can be categorized in the following manner:

  • user initiated events-- the user performs some action in the user interface, e.g., button click
  • external (network) events, e.g., a text arriving, GPS information arriving
  • timer events -- the passing of time is considered an event and used for animation
  • initialization event -- the app being launched is considered an event. Screen1.Initialize is the event-handler.

d. What is an event-handler?

The app's behavior consists of a set of event-handlers. An event-handler is an event together with the function calls an app will perform in response:

    event ----->  function call 1

                        function call 2

                        ...

                        function call n

e. What is a "call"?

To call a function means to invoke it. The phone has a function Sound.Play. When you click the button in HelloPurr, you call the function Sound.Play-- you tell Android to do it.

5. For the HelloPurr app, name the:

for part I:

components: There is a label displaying "Pet the Kitty" and a button you click to make it happen.  The enclosing screen is also considered a component, and there is a non-visual Soundcomponent.
a few properties: Amongst others the label has a text property set to "Pet the Kitty" and the button has an Image property set to the picture of the kitty.
events: Button1.Click -- when the user clicks a button action occurs.
event-handlers: There is one event-handler:

It includes a when block for the event Button1.Click, as well as a single response block, the call to the Sound1.Play function.

calls to functions: Sound1.Play


6. Some calls to functions require arguments (also known as parameters). Which calls in HelloPurr require arguments?

Part II of Hello Purr has a function with a parameter. In that second part, you add a Sound1.Vibrate function call so the phone will vibrate when you "pet" the kitty:

Unlike Play, the Vibrate function has a parameter. The name of the parameter is millisecs and in the tutorial you plug in the number 500 into it. A millisecond is 1/1000 of a second, so this means the phone will vibrate for 1/2 second.

A parameter is data the function needs to do its job. The Vibrate function needs to know how long to vibrate. Later we'll work with a MoveTo function that moves an image sprite. It will have two parameters, one for how much to move horizontally in the x-direction, and one for how much to move vertically in the y-direction.

Comments