bitrazor.com ...THE source for mediocre content                                      

Day 5: Adding Real Functionality             

<< Back to Tutorial Home< Back to Day 4 - Forward To Next Steps >

Well, we've done just about everything except for actually making the application DO something.  Well, now's the time. 

We're going to make some changes to our ViewScreen class -- some fairly extensive ones, actually.  I'm going to explain the changes here, and I'll link in the source, since the changes are too big to really be practical showing here.

What It Does

We'll use some traffic cameras from Colorado Springs, CO.

We're going to choose 4 of these cameras, then rotate through them every 6 seconds.

Changes to ViewScreen & Other Details

  • First, I heavily leveraged 'Pictures.java', one of the classes from the HME SDK samples.  I was able to use most of the code there.
  • I had to change getScaledImage() (line 124) to create the image from a URL, not a local filesystem path.
  • I created a method called getCameraURLs() (line 78) that has the hardcoded URLs in it.  This should eventually be replaced with a read from a config file, or some better solution.
  • ViewScreen now extends BScreen, not ScreenTemplate, since we don't want a background or title.  This also means I had to add the key press handler routine to it.

Download ViewScreen

Download the updated version of ViewScreen.java and replace your copy of it with this one.

Run It

Run it in the Simulator.  Select 'View Traffic Cameras' and you should see something like this set of screens rotated through:

etc.

Problems?

If you get an exception, double-check the URLs listed; if this tutorial has been out for a while, they might have changed some of the URLs for the images.  Right now, the code just throws an exception or otherwise misbehaves.  Paste each into your browser, and simply comment out any that don't work.

That's It!!!

Congratulations -- you have successfully written a complete TiVo application that actually does something useful.  I hope this has been useful.  I'm sure you have lots of ideas of how to improve the application from here.  Go to the Next Steps for a list of possible improvements, adn to download a completed, commented version of this project.

<< Back to Tutorial Home< Back to Day 4 - Forward To Next Steps >

                                                         Last updated: August 25, 2006