App Inventor Day 1 PDF
App Inventor Day 1 PDF
●
Introduction to App Inventor
●
Training Plan
●
Interface and Control
●
Block programming
●
Mini-Project
1
Introduction to App Inventor
●
Created by MIT Computer Science & Artificial
Intelligence Laboratory
●
Visual programming environment for Android
phones and tablets
●
Programming editor based on Blockly
●
Other Blockly based editors:
– Blockly Games
– Code.org
– MakeCode (used for micro:bit)
2
Introduction to App Inventor
●
Primarily used for teaching coding, but
many have created practical and useful
apps using it
– App to help blind navigate around the
school in Texas
– Crowd-sourcing app to locate safe drinking
water in Moldova
– App to help parents track students on
buses
3
Training Plan
●
Day 1: Intro and Basics
●
Day 2: Sprites and Graphics
●
Day 3: GPS, Map, inter-app
communications
●
Day 4: Camera, File, Physics
●
Day 5: Project Work
●
Day 6: Project Presentation
4
Setting Up (Part 1 of 2)
●
Visit http://appinventor.mit.edu or do a
search for “app inventor”
●
Click “Create apps!”
●
Login with your Google Account (create
a new account if you don’t have one)
5
Interface and Control
Palette
Where you select
and drag
components into
the viewer
6
Interface and Control
Viewer
Represents your
phone. You can drag
components in
here.
7
Interface and Control
Components
List all added
components.
Screen1 is already
added by default,
and you can add
multiple screens if
needed.
8
Interface and Control
Media
List all uploaded
media (eg. sound,
images).
9
Interface and Control
Properties
Allow you to change
properties for any
component (eg.
change background
color of a button)
10
Creating Our First Interface
Upload 2 or more
images through the
media window
12
Setting Up (Part 2 of 2)
●
On your Android phone, go to the Play
Store and search for “mit ai2
companion”
●
The app author should be “MIT Center
for Mobile Learning”
●
Install the app
13
Connecting App Inventor
15
Block Programming
Blocks window /
palette
Click to open a list of
available blocks
16
Block Programming
Viewer
Area where you drag your
blocks to program your
app
17
Programming the App
Event-driven programming
Programming for graphical user interface typically
uses an event-driven approach. In this approach,
the program flow occurs in response to an event.
The “when” block above represents an event.
Select your
spinner... While any programming language can be used with
an event-driven approach, most introductory
courses in programming uses a procedure-driven
approach. 18
Programming the App
19
Programming the App
Warnings and Errors
After the last step, you should see this at the bottom left
of your viewer.
Error
An unrecoverable problem. The program cannot continue.
Warning
The program encountered a problem, but can still continue.
For example; in the current case, since we didn’t provide a
filename, the program will assume we are setting it to a blank
and continue based on that.
21
Programming the App
22
Programming the App
●
Try out the app on your phone
●
If it doesn’t work, try checking...
– Under “ElementsFromString” are the values
the same as the filename in media?
– App Inventor may change the filename
upon upload. Double check that the names
match!
– Try reseting the connection between your
browser and your phone
23
Adding Components
24
Adding Components
The “TextToSpeech”
component will appear at
the bottom, as it is not a
visible component.
25
Adding Components
What if we want the button to be on the right of the text box? You
can’t just drag it into position!
27
Adding Components
Add in a checkbox and set the
text to “Talk fast”
28
Programming the App
Select your
button...
29
Programming the App
Empty Text
Next, select
TextToSpeech...
30
Programming the App
33
Challenges
●
We haven’t used the textbox yet. Make
the app speak the text in the textbox.
●
Bonus Challenge: Explore the
YandexTranslate component (found
under media). Can you make the app
translate the text to Spanish and speak
it? (Tip: Language code for Spanish is
“es”)
34
Mini-Project
●
Create a fortune telling app
●
The machine should produce a
random fortune each time you shake
it
●
Fortune can be visual, spoken, or
both
●
Bonus:
– Add in sound effects
– Add in a gender selection, and change
your fortune text to reflect the user’s
gender
– Add in graphical effects
35