Tuesday, January 26, 2010

Project KL Traffic Cam

Got Android? Live in Malaysia? Need to view traffic conditions in Kuala Lumpur? You're in luck, because CodeAndroid Malaysia has just the thing. KL Traffic Cam is an application that provides easy access to video feeds provided by ITIS Malaysia. The streams are available at their WAP site and accessible via your standard browser. I will add though that the application is much more convenient and allows you to save a list of favourite cams as a typical user is often concerned with traffic conditions on one or two major highways. It also provides an easy way to access ITIS WAP site, all from within the application.

Tech talk
The application utilizes Android's built-in video streaming capabilities. Broadcast an Intent and it fires up a video streaming component without needing a single-line of code. This is part of the reason the entire application was up and running in a record 8 hours or so (albeit with some bugs)!

It also utilizes the sqlite3 database on Android to store a user's favourite list of cams. The API is easy to use and I foresee many developers will feel right at home with accessing the database on Android. There is file access for storage as well, but I decided to utilize the database for its ACID properties. I don't really trust myself for handling file flushes should my application crashes.

I experimented a bit with the UI - using backgrounds, images and icons to see how themes and styles are handled in Android. Maybe it's just me but I find that it's not as easy as it looks. I really have profound respect for devs that have good looking apps, seriously. The API Demo sample app helped tremendously. The free DroidDraw works great for simple layouts too. But in the end, there's no escaping the dreaded API available at Android's Developer site as well as blog post by Romain Guy.

A last minute feature was the easy access to ITIS existing WAP site which provides additional information such as traffic announcements as well as images of the highways (important if you're not using an unlimited data plan or wifi). To do this, I utilized Android's WebView which is really handy to display URLs or any HTML content. Had to hack around with key-press event handling because unlike the default behaviour of the Android's web browser, hitting BACK does NOT navigate to the previous page. Instead, pressing BACK will actually bring up the previous Activity, not something I want.

Well, no point in talking too much I guess - sources are available at Google code should anyone be interested. The code is quite new-bish but hey, this is my first completed Android project.

TODO
I'm thinking of using Google Maps to display cam locations. And maybe provide an option of just displaying images instead of video stream to cater for bandwidth limited users. Finally, perhaps scrapping and displaying traffic notifications from ITIS WAP site. And of course, closing all the bugs.

DOWNLOAD
Google Code
SlideME

SCREENSHOTS




2 comments:

Leong Hean Hong said...

Good job, Bernie! It is amazing you can create such an useful app in just 8 hours.

You have shared your development decisions (i.e. choosing db over file, using intent, ...) in the blog, I think that is very beneficial to readers.

Alvin said...

this local app rocks! :D

Post a Comment