• No results found

ACS-1805 Introduction to Programming (with App Inventor)

N/A
N/A
Protected

Academic year: 2021

Share "ACS-1805 Introduction to Programming (with App Inventor)"

Copied!
17
0
0

Loading.... (view fulltext now)

Full text

(1)

ACS-1805

Introduction to Programming

(with App Inventor)

Chapter 13

(2)

What We Will Learn

In this chapter we will learn

The Texting component for sending texts and processing

received texts

 An input form for submitting the custom response

message

The TinyDB database component for saving the

customized message even after the app is closed

 The Screen.Initialize event for loading the custom

response when the app launches

The TextToSpeech component for speaking texts aloud The LocationSensor component for reporting the driver’s

(3)

Designing the Components

(4)

Designing the Components

(5)

Designing the Components

 Set the properties of the components in the following

way

Set the Text of PromptLabel to “The text below will be sent in response to all SMStexts received while this app is running.”

Set the Text of ResponseLabel to “I’m driving right now, I’ll

contact you shortly.”Check its boldness property

Set the Text of NewResponseTextbox to “ ”. (This leaves the text box blank for the user’s input.)

Set the Hint of NewResponseTextbox to “Enter new response text” Set the Text of SubmitResponseButton to “Modify Response”

(6)

Auto-Responding to a Text

 You’ll use App Inventor’s Texting component

 First you set the phone number to which the text should be sent

It is a property of the Texting1 component.

 Next you set the message to be sent

It is also a property of Texting1

 Finally, you actually send the text with the

(7)

Entering a Custom Response

Add blocks for the user to enter some custom

response

 The app will copy the entry (NewResponseTextbox) into

the ResponseLabel

(8)

Storing the Custom Response Persistently

There is one catch so far

The custom response the user enters will disappear after

the user closes the app and relaunches it

The custom response is transient data

 It is stored in component properties

To address such problem

To make your app to remember something persistently

 You have to transfer it from short-term memory to long-term memory

(9)

Storing the Custom Response Persistently

To store data persistently in App Inventor

you use the TinyDB component

It stores data in a file on the Android device

TinyDB provides two functions

StoreValue

 The app can store information in the device’s database  Typical scenario: Store data to the database each time the

user submits a new value

GetValue

 The app can retrieve information that has already been stored

 Typical scenario: When the app launches, load the data from

(10)

Storing the Custom Response Persistently

Modifying SubmitResponseButton.Click

(11)

Retrieving the Custom Response When the App Opens

 If you want to take some action when the app launches

 You need to use the Screen1.Initialize event handler

 There is another catch

 For the first time the user opens the app

there won’t be any custom response in the database to load

 so you want to leave the default response in the

ResponseLabel

(12)

Speaking the Incoming Texts Aloud

Make modification to the app

so that when you receive a text the sender’s phone

number along with the message is spoken aloud

 The idea here is to provide the scratch to the itch in your

mind

The temptation to check the text when you’re driving and hear a text come in

Android devices provide text-to-speech

capabilities

 App Inventor provides a component that will speak any

(13)

Speaking the Incoming Texts Aloud

Make modification to the app

 so that when you receive a text the sender’s phone number

along with the message is spoken aloud

 The idea here is to provide the scratch to the itch in your mind

The temptation to check the text when you’re driving and hear a text come

in

Android devices provide text-to-speech

capabilities

 App Inventor provides a component that will speak any text you give it

(14)

Speaking the Incoming Texts Aloud

You’ll use TextToSpeech.Speak within the

Texting.MessageReceived event handler

 Use the "join" block to combine separate pieces of text

(or numbers and other characters) into a single text object

(15)

Adding Location Information to the Response

Some further enhancement

you can use location tracking to convey a bit more

information in the auto-response to incoming texts

 App Inventor provides the LocationSensor component

for interfacing with the phone’s GPS

The LocationSensor can provide

 latitude  longitude

 the driver’s current street address if tapped into Google Maps to provide

Note that LocationSensor doesn’t always have a reading

It gets a reading only when your phone's location is

(16)

Adding Location Information to the Response

Sending the Location as Part of the Response

 You can modify the Texting1.MessageReceived event

handler to add location information to the response

(17)

References

Related documents

Of course, we also need to change every RadiusLabel.Text expression in the Canvas1 event handlers to instead refer to the current value in the global variable:. The state of

In this tutorial, you will learn about animation in App Inventor by making a Ball (a sprite) bounce around on the screen (on a Canvas).. Start a

Roughly, these correspond to the two main windows you use in App Inventor: you use the Component Designer to specify the objects (components) of the app, and you use the Blocks

Under Cheese in ‘My Blocks’ you will find ‘set Cheese.Visible to’, drag this into the EatCheese procedure.. In ‘Built-In’ under Logic you will find false, drag this into

• Can develop a wide range of apps – Communication, Finance, Media, Tools etc • Ability to integrate various smartphone • Ability to create your own art and customise. Sound

1135 (2013) (proposing a “baseball style” arbitration that should reduce the range between the royalty demands of patentees and the offers of licensees, thus simplifying

As higher education professionals look to use Relationship Marketing Theory to guide their marketing practices, they should keep in mind that students look to social media

However, this endogeneity bias cannot explain the findings presented in this study since it would predict more hours of work with higher income, whereas these bargaining power