Mobile Programming (MIT App Inventor 2)

Similar documents
PaintPot. Figure 2-1. The PaintPot app

CHAPTER 1 HelloPurr. The chapter covers the following topics:

Hello Purr. What You ll Learn

Introduction to Android Programming

What You ll Build. CHAPTER 3 MoleMash

Mobile Apps with App Inventor

Named Memory Slots. Properties. CHAPTER 16 Programming Your App s Memory

App Inventor Tutorial 4 Cat & Mouse Game

App Inventor Beginner Tutorials

MIT App Inventor Getting Started Guide

TalkToMe: A beginner App Inventor app

Or working offline with the local server: Once you have the App Inventor running type into your browser

Xylophone. What You ll Build

App Inventor Drum Machine Instructions (Project #1) (Version 2 of App Inventor) Description:

Android Programming Family Fun Day using AppInventor

I Have a Dream, a Two-Part Introductory Tutorial

Mobile App Design Tool for Smartphones: A Tutorial

Getting started 7. Designing interfaces 27

Ladybug Chase. What You ll Build. What You ll Learn

CHAPTER 14 Understanding an App s Architecture

Educational App Development Toolkit for Teachers and Learners

Creating Animated Apps

App Inventor 2 Workbook. Quiz Development

PlanGrid. User Guide.

Fusion Voic Plus User Guide For Android Devices

American Sign Language Alphabet App (Project #2) (Version 2 of App Inventor) Description:

Scientific m-learning. 4-7 June Mobile Application Development using App Inventor for Android Devices

Getting Started. Version 3.1 Last updated 2014/3/10. Orbweb ME: Getting Started

You can learn more about Stick around by visiting stickaround.info and by finding Stick Around on social media.

Netigate User Guide. Setup Introduction Questions Text box Text area Radio buttons Radio buttons Weighted...

Using the owncloud Android App

Online Testing Checklist for Summer 2016 Ohio s State Test Administrations

Adobe Connect and Zoom are web conferencing tools with many features. Google Hangouts and Skype are primarily for voice calling or text chat.

WEB MAPPING TOOL DOCUMENTATION

LEARNING RESOURCE CENTRE. Guide to Microsoft Office Online and One Drive

P WEBSITE P CATALOGUES P PRICE GUIDES P ONLINE CLOUD STORAGE P e-commerce System. Printed and Electronic (e-documents) Users Guide. vbradug

Mobility with Eye-Fi Scanning Guide

Technology guides for the classroom. File Sharing. (using QR Codes and Dropbox in the ipad classroom)

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

Apps for Android. Apps for iphone & ipad INS584-3

Cloud Storage Service

SweetPea3R-200 User Guide Version 1.1

Mobile Print/Scan Guide for Brother iprint&scan (Android )

Kaldeera Workflow Designer 2010 User's Guide

Mobile Print/Scan Guide for Brother iprint&scan

User Guide. Chapter 6. Teacher Pages

This guide describes features that are common to most models. Some features may not be available on your tablet.

DESIGNING YOUR WEBSITE. The following guide will show you how to setup your music website using

Samsung Xchange for Mac User Guide. Winter 2013 v2.3

GOOGLE FINANCE PORTFOLIO INSTRUCTIONS

CTvox for Android. Version 1.5

CHAPTER 11 Broadcast Hub

RDM+ Remote Desktop for Android. Getting Started Guide

Using the T&D Thermo App with TR-7wf Data Loggers

MicroStrategy Quick Guide: Creating Prompts ITU Data Mart Support Group, Reporting Services

MICROSOFT OUTLOOK 2011 GETTING STARTED AND HELP RESOURCES

SMART Board Tips & Tricks (version 9.0) Getting Started. SMART Tools vs. SMART Notebook software

Downloading the GAIG Annuity App. Log In Screen. Home Page

SMART Board Menu. Full Reference Guide

Create a Poster Using Publisher

ipad Basics Tips from the October 16, 2014 ipad Basics Class Tip No. 1 Apple ID Where is it found? Settings>iCloud>Apple ID

TalkToMe Part 2: Shaking and User Input

How To Use Textbuster On Android (For Free) On A Cell Phone

How To Sync Google Drive On A Mac Computer With A Gmail Account On A Gcd (For A Student) On A Pc Or Mac Or Mac (For An Older Person) On An Ipad Or Ipad (For Older People) On

HELPDESK SYSTEM (HDS) USER MANUAL

User Guide January 10

Setting up AI Prime or Hydra HD. There are two ways to connect the Hydra HD 52/26 or Prime.

Tutorial for Android users *with the CONNECTED WATCH App

Online Tools Training Lesson Plan

Once you have obtained a username and password you must open one of the compatible web browsers and go to the following address to begin:

Secure Share (Novell Filr) Remote Teacher Video Sharing Process School Year

User Guide Novell iprint 1.1 March 2015

Using Flow Control with the HEAD Recorder

This guide describes features that are common to most models. Some features may not be available on your tablet.

action sports game tutorial for App Inventor 2

How to create database in GlycomcsPortal?

Using Devices. Chapter 3

ASUS WebStorage Client-based for Windows [Advanced] User Manual

Initial Setup of Microsoft Outlook with Google Apps Sync for Windows 7. Initial Setup of Microsoft Outlook with Google Apps Sync for Windows 7

XMEye Android Mobile Monitoring Client English Manual

E-Loader Operation Manual

Educational (Android) App Development Toolkit for Students

Accessing Derbyshire County Council s Outlook Web Access (OWA) Service. Smart Phone App version

Sample only. Unit 4a Lesson 1: Pop game 50 minutes. Cross-curricular links. Overview. Learning objectives. Success Criteria. Key words. 1.

REFERENCE GUIDE 1. INTRODUCTION

Organizational Development Qualtrics Online Surveys for Program Evaluation

How To Use Senior Systems Cloud Services

App Inventor Tutorial 11 QR Code Reader

How To Write A Cq5 Authoring Manual On An Ubuntu Cq (Windows) (Windows 5) (Mac) (Apple) (Amd) (Powerbook) (Html) (Web) (Font

Store & Share Quick Start

Backups User Guide. for Webroot SecureAnywhere Essentials Webroot SecureAnywhere Complete

The Tacx Cycling app (ios and Android) Quick start guide

Go Kiwi Internet Content Management System Version 5.0 (K5) TRAINING MANUAL

Task Card #2 SMART Board: Notebook

a basic guide to video conversion using SUPER

Secure Share (Novell Filr) Remote Teacher Video Sharing Process School Year

You will need your District Google Mail username (e.g. and password to complete the activation process.

Please refer to the guide below to use the latest Android version of the UCam247Live app.

Transcription:

Mobile Programming (MIT App Inventor 2) http://www.plk83.edu.hk/cy/ai2 Contents 1. Understanding the working environment (Page 1) 2. First Android Program (HelloPurr) (Page 4) 3. Completing HelloPurr (Page 8) 4. PaintPot (Page 10) 5. Basic Android Programming (Page 14) 6. MoleMash (Page 19) 7. Further Skills (Page 21) (Screen properties, Changing Screen Display, Multiple Screens, Camera, List and Database, Image Picker, Player, Text To Speech, Speech Recognizer) Understanding the working environment 1. Create an email account in Google. (http://mail.google.com) -OR- Using the provided Gmail account as below. User name: <your registration number>@student.plk83.edu.hk (e.g. 08m001@student.plk83.edu.hk) Password: <your HKID card number> (e.g. A1234567) 2. Open the MIT App Inventor (http://ai2.appinventor.mit.edu/) with the Google Chrome browser and log in with your Gmail account. 3. Click the "Guide" hyperlink. Page 1 of 29

4. Click "Resources" Get Started and read the Setup Instructures. There are three options to test your build apps. In option one; an app should be installed in the mobile device, what is the name of the app? In the lessons, students should use option two and install the App Inventor Setup Software. Page 2 of 29

App Inventor consists of the Designer and the Blocks Editor. (i) App Inventor Designer Design the App's User Interface by arranging both on and off-screen components. (ii) App Inventor Blocks Editor Program the app's behavior by putting blocks together. Page 3 of 29

First Android Program 1. Download the kitty picture (kitty.png) from the following web site http://www.plk83.edu.hk/cy/ai2/ 2. Click New Project button on the left side. Enter the project name as HelloPurr. 3. Drag and drop the Button component to Screen1. The name of the component will be Button1. 4. Click on Button1 and add the kitty picture as the image property. 5. Delete Text for Button1 listed under the Text property. Page 4 of 29

1. Run the aistarter program. 2. Click Connect and then Emulator. Wait for a few minutes. 3. Now you can run the program in the emulator. Page 5 of 29

Alternatively, you can test the apps with an Android device with the following steps. 1. Install the app "MIT AI2 Companion" in the Android device. 2. Click Reset Connection if you have opened the emulator. 3. Click Connect and then AI Companion. 4. Use the "MIT AI2 Companion" to scan the QR Code. Page 6 of 29

To run the program in the android device, you can download the package (an apk file) and install it in an Android device. 1. Click Build and then App. 2. Use the "MIT AI2 Companion" to scan the QR Code. 3. Complete the installation process in the Android device. You can use the HelloPurr app in the Android device with two methods (use the Connect and Build menus). What is the difference between them? Project Management 1. Click My Projects at the right hand side. 2. Select the HelloPurr project. 3. Click Project and then you can export or import the project file. Note: You can find the above project (HelloPurr.aia) in http://www.plk83.edu.hk/cy/ai2/. Page 7 of 29

Completing HelloPurr 1. Select the HelloPurr project. 2. Click Project and then Save project as. 3. Name the new project as Complete_HelloPurr. 4. Open the Complete_HelloPurr project. 5. Add a Label component. Its name is Label1. 6. Enter Pet the Kitty in the Text property of Label1. 7. Change the BackgroundColor, TextColor and FontSize properties of Label1. 8. Expand the Media section and drag and drop the Sound component to Screen1. Its name will be Sound1. 9. Download the mp3 file (meow.mp3) from http://www.plk83.edu.hk/cy/ai2/ and set meow.mp3 as the Source property of Sound1. Page 8 of 29

10. Open the Blocks Editor. 11. Click Button1 and drag and drop the when Button1.Click do block onto the editor. 12. Click Sound1 and drag the call Sound1.Play block onto the editor as shown below. 13. Run the program with the emulator. You can click the kitty picture and hear the kitty meow. Page 9 of 29

PaintPot 1. Open the MIT App Inventor (http://ai2.appinventor.mit.edu/) and log in with your Google email account. 2. Complete the PaintPot program. The demonstration videos can be found in http://www.plk83.edu.hk/cy/ai2/ Part 1: Component Name Property Value HorizontalArrangement ThreeButtons Width Fill parent Button ButtonRed BackgroundColor Red Text Red Button ButtonGreen BackgroundColor Green Text Green Button ButtonBlue BackgroundColor Blue Text Blue Canvas DrawingCanvas BackgroundImage Kitty.png Width Fill parent Height 300 pixels Button ButtonWipe Text Wipe Page 10 of 29

Study the Block Editor carefully; can you identify the following elements? 1. Event 2. Command 3. Argument You can use the copy and paste method to make similar blocks. Note Show your work to your teacher. Page 11 of 29

Part 2: Add three new components. Component Name Property Value HorizontalArrangement HorizontalArrangement1 Button ButtonBig Text Big Dots Button ButtonSmall Text Small Dots Modify the following event. Change this argument Page 12 of 29

First, define a new variable called dotsize. Use the value of dotsize to draw the circle. Define two new events to modify the value of dotsize. More to do Using the following command and add two new buttons such that we can draw thick lines and thin lines. Show your work to your teacher. Page 13 of 29

Basic Android Programming App Inventor Designer Some standard user interface components. Component Event Description Click() User tapped and released the button. LongClick() User held the button down. Changed() Detect user taps and can change their Boolean state in response. Component Properties Description Picture The file name of the picture. Visible Text FontSize TextColor Visible Text Enabled TextAlignment Specifies whether the component should be visible on the screen. Text to display on label. Point size for label text. Color for label text. Specifies whether the component should be visible on the screen. The text in the input box. Whether the user can enter text into this input box. Whether the text should be left justified, centered, or right justified. App Inventor Block Editor Some Build in Blocks Math Addition, subtraction, multiplication and division operators. Find the power. Relational operators. The result is either True or False. Page 14 of 29

Logic Two logic values. Logical operators. Control Selection. Looping. Variables Initialize new variable. Set and get the value of a variable. Procedure Define and call a procedure. Define and call a procedure that will return a result. Page 15 of 29

Example The following app can display the total price when buying some apples. The unit price of apple is $5. Discount will be given when buying more apples (details in the following table). Number of apples purchased Discount percentage 1-9 0% 10-19 10% 20 or above 20% At the beginning, the Text property of the Label 'Results' should be blank. Then, enter the number of apples in the TextBox 'Apples' and click Button1. Page 16 of 29

The app can only allow the input of numbers. How can this be achieved? You can download the above source program from http://www.plk83.edu.hk/cy/ai2/ More to do 1. Add the dollar sign ($) in the results. 2. Prevent the input of negative numbers. 3. The unit price of apple may be changed from time to time. Suggest one modification such that the app can be used for changing unit price. Note Show your app to your teacher. Page 17 of 29

App Design 1 In general, if we deposit principal $P for n periods with the interest compounded r% per period, then the amount $A can be calculated by the following formula. A = P x (1 + r%) n And, the compound interest $I is given by the following formula. I = A P Design an app to accept the inputs of principal ($P), interest rate (r%) and number of periods (n), and output the amount ($A) and compound interest ($I). App Design 2 Study the following salaries tax table. Salaries tax based on the net chargeable income (2008/09) Net chargeable income Tax rate Salaries tax ($) On the first $40 000 2% 800 On the next $40 000 7% 2800 On the next $40 000 12% 4800 Remainder 17% -- Design an app to input the net chargeable income and output the salaries tax payable. Note Show your apps to your teacher. Page 18 of 29

MoleMash 1. Download the mole picture (mole.png) from the web site http://www.plk83.edu.hk/cy/ai2/ 2. Open the MIT App Inventor (http://ai2.appinventor.mit.edu/) and log in with your Google email account. 3. Complete the MoleMash program. The demonstration videos can be found in http://www.plk83.edu.hk/cy/ai2/ Component Name Property Value Screen Screen1 Title MoleMash Canvas MyCanvas Width 300 pixels Height 300 pixels ImageSprite Mole Picture Mole.png Label ScoreLabel Text Score: 0 Button ResetButton Text Reset Sound Notify Clock MoleTimer TimerInterval 1000 Page 19 of 29

Open the Block Editor. 1. The variable score is defined to store the score of the game. 2. Two procedures MoveMole and UpdateScore are defined such that they can be called again and again. In the MoveMole procedure, the random fraction will generate a random number from 0 to 1 such that the Mole can get the new x and y coordinates. 3. When the MoleTimer is triggered (every 500ms), the MoveMole procedure is called. 4. When touching the Mole, one mark will be added to the score and other consequences will be triggered. 5. Finally, the reset button can reset the score to 0. Page 20 of 29

More to do 1. Add a sound effect when the Mole is touched. 2. Add one more moving Mole (with different moving speed) in the game. (Hint: Add one more ImageSprite and one more Clock component.) 3. When touching the two different Moles, different scores can be obtained. 4. If the Mole cannot be touched, one mark should be deducted. (Hint: Use the following event and the following logical test Deduct the score here. to check whether it is failed to touch any ImageSprite on the Canvas.) Further Skills (A) Screen Properties Study the meanings of various properties. Page 21 of 29

(B) Changing Screen Display Use the TableArrangement component to store some components such that we can show or hide these components by changing the Visible attribute of TableArrangement to true or false accordingly. You can download the above source program from http://www.plk83.edu.hk/cy/ai2/ (C) Multiple Screens App Inventor supports multiple screens. Use the Add Screen button to create a new screen. Then use the open another screen command to open a new screen. However, the open another screen command cannot be used in the emulator. You have to test this app in an Android device. Page 22 of 29

Something to do Create an app with the following requirements. 1. Landscape screen orientation. 2. Screen title is "Animals". 3. Yellow colour background. 4. Two buttons to show a dog and a cat respectively. (D) Camera Invisible component Camera is used to activate the camera function. Click Button1 to take a photo. After taking the photo, the photo is displayed as the background image of Canvas1. However, the Camera component cannot be used in the emulator. Page 23 of 29

You can use the skills in PaintPot to draw on the canvas. To save the background image of the canvas, first enter the file name in TextBox1 and then click Button2. If the file name is not empty, the picture will be stored in a folder called AI2. Notifier component can be used to pop up a message on the screen. You can download the above source program from http://www.plk83.edu.hk/cy/ai2/. (E) List and Database Two invisible components TinyDB and Notifier are used in the app. TindyDB is a database component and it can store data in the Android device permanently. ListPicker component can display an item in a list. Lists store data temporarily. Page 24 of 29

Two lists are defined to store the names and birthdays respectively. (A list contains multiple items.) Two databases (NameDB and BirthdayDB) are used to store the above two lists respectively. List Database Name NameDB Birthday BirthdayDB Page 25 of 29

Command TinyDB1.GetValue is used to read the stored data from the database when the app is opened. We should not assign the read data to the two lists directly. Do you know why? Click Button1 to add the name and birthday to the two lists respectively. Then store the two lists in the corresponding databases. Page 26 of 29

The ListPicker component can pick up an item in the list. Do you understand the above program block? You can download the above source program from http://www.plk83.edu.hk/cy/ai2/. More to do 1. Can you write a block to delete the wrong data? Hint Add another ListPicker and use the following command to remove the items in the two lists and update the two databases. 2. Use the component to input the birthday in order to reduce input mistakes. Page 27 of 29

(F) More Components ImagePicker Pick an image in the device's image gallery. Player You have to specify the source of the player. You can download a song (song.mp3) from http://www.plk83.edu.hk/cy/ai2/. You can Start, Pause or Stop the Player. TextToSpeech Use it to speak out the text. Page 28 of 29

SpeechRecognizer Use it to convert the spoken sound to text. You can download the above source program from http://www.plk83.edu.hk/cy/ai2/. Page 29 of 29