02-The Connected World

Homework required in preparation for this lecture (1.5 hours estimated time, and 2 hours on PA4 and incubator )

  • Read Chapter 7 (pp. 130-160) and get the LocalBrowser and Translate applications running on your phone or other device (look up code via googling "hello android pragmatic" and downloading the code). These applications demonstrate critical concepts and techniques which you will use in your incubator projects. Make some superficial modifications to the code (e.g. add your name to the UI somewhere) and create a short screencast showing your modifed code running in the simulator (or make a movie of it running on your phone or other device) [1 hour reading @ 2min/page, 30 minutes downloading and modifying code, 10 minutes making/posting video]
  • Write a short blog post explaining what you thought were the most subtle concepts in this Chapter, be prepared to explain any features that you didn't feel were particularly subtle! [15 minutes]
  • Write a blogpost giving three ways you might be able to use some of the material in this chapter in your incubator project, and comment on three other blogs. Call the blog "WebView in my app."  Be specific (e.g. one easy application is to create a set of help pages in HTML/CSS/javascript).[15 minutes]
Also spend at least 1 hour working on PA4 and at least 1 hour to complete at least one story for your incubator project.


Learning Objectives:
  • understand how to embed a WebView inside an android application and the way in which the javascript interpreter and the android engine interact
  • understand how to design an android application that interacts with a web service

Main topics to cover. We will use a code review approach where students will be called on (randomly) to explain parts of the code in Chapter 7.

Work through example of WebView window with two way communication between javascript engine and android. We will go over the code closely and have students ask questions and explain the code.

  • WebView class  where is it created and where does it appear in the application?
  • content -- where is the content for the webview stored (i.e. the file containing HTML and javascript)
    • how would you create a multipage website with photos and links?
  • javascript calling android code
    • how is this done in this example?
    • what kind of changes could we make to this code
  • android code invoking javascript methods
    • how is this done in this code?
    • what kind of changes could we make

Work through example of Translation app showing how to communicate with a server. We will also read this code closely and make sure everyone understands what it does.Translation App Key Ideas:

  • How are the lists of languages generated in the GUI
    • related question -- what are Adapters and Spinners
  • How does the application continuously read from the keyboard and make translations in real time?
    • what is the Executor class and why is it being used? are there alternatives?
    • why is there a 1000ms delay
    • why do they use the Handler class? are there alternatives?
  • What if we didn't want to have continuous translation? Would we still need threads?

PA2 code examples


  • Work on Incubator Projects, verify story priorities with clients
  • Discuss Homework for tomorrow