6.S198 Lecture Feb. 11 2015

advertisement

ComPal - Combur Test Analyzer

Step 1 : Choose a swatch orientation

Step 2 : Line the test strip up with

reference dots

Step 3 : Take a picture

Step 4 : Receive an

instant diagnosis

Image taken from the camera

Activity starter

Using the activity starter: Web search

Action: android.intent.action.

WEB_SEARCH

Using the activity starter: Map

Action: android.intent.action.

VIEW

Using the activity starter: YouTube

Action: android.intent.action.

VIEW

Using the activity starter: WEB_SEARCH

Action: android.intent.action.

WEB_SEARCH

Using the activity starter: SEARCH

Action: android.intent.action.

SEARCH

Apps with multiple screens

Accessing a Web service with HTTP GET

URL: http://finance.yahoo.com/d/quotes.csv?

f=l1&s=MSFT

Result:

42.36

Accessing a Web service with HTTP GET

URL: http://finance.yahoo.com/d/quotes.csv

?

f=l1&s=MSFT

Base URL

Result:

42.36

Accessing a Web service with HTTP GET

URL: http://finance.yahoo.com/d/quotes.csv

?

f=l1&s=MSFT

? marks start of arguments

Result:

42.36

Accessing a Web service with HTTP GET

URL: http://finance.yahoo.com/d/quotes.csv?

f=l1 &s=MSFT

First arg

Result:

42.36

Accessing a Web service with HTTP GET

URL: http://finance.yahoo.com/d/quotes.csv?

f=l1 & s=MSFT

& character separates args

Result:

42.36

Accessing a Web service with HTTP GET

Yahoo finance API (old version)

URL: http://finance.yahoo.com/d/quotes.csv?

f=l1& s=MSFT

Second arg

Result:

42.36

Using a service with the App

Inventor Web component

Event-driven operation

Execution proceeds immediately.

There is no waiting here.

New style Yahoo finance API http://query.yahooapis.com/v1/public/yql?

q=select%20*%20from%20yahoo.finance.

quotes%20where%20symbol%20in%20%28%

22MSFT%22%29&env=store://datatables.

org/alltableswithkeys

Result returned in XML

New style Yahoo finance API http://query.yahooapis.com/v1/public/yql?

q=select%20*%20from%20yahoo.finance.

quotes%20where%20symbol%20in%20%28%

22MSFT%22%29&env=store://datatables.

org/alltableswithkeys% format=json

Result returned in JSON

Blocks for working with JSON

Takes JSON object –

{"symbol":"MSFT","Ask":"42.59“, "AverageDailyVolume":"

35207200",

"Bid":"42.58“, ... }

Returns a list of key, value pairs:

Takes list of key, value pairs and a key

((symbol MSFT) (Ask 42.59) ... )

Ask

Returns the corresponding value

42.59

Food Explorer App

URL must include an App Id and an API key

https://api.nutritionix.com/v1_1/search/?

the_food

?results=0:5

&fields=item_name,brand_name,brand_id,item_id,nf_calories

&appkey= the_API _key

&appId= the_App_Id

Download