Dev Case Study: Fonolo, Part One
The Dev Case Study series highlights Android application projects, focusing on the thoughts and perspectives of the developers who wrote the application in question.
This week’s case study is the Android client for Fonolo. The Fonolo service is for “deep-dialing”, helping you bypass long phone menus to get to the person you are seeking. People at Fonolo map out phone trees and have a phone system that can connect you to the tree, but then does the phone tree navigation for you. You just get to talk to whoever you are trying to reach, without dealing with all of the “press 1 for…” delays. They even let you bookmark specific phone tree leaves and can re-dial those as needed without even having to wade through Fonolo’s GUI. If you deal with big phone trees a lot, this can be quite the benefit.
The Fonolo service has an API, and a three-person team from the University of Oregon (Go Ducks!) wrote an Android client using that API. In this interview, I (AG) ask John St. John (JSJ), Craig Gardner (CG), and Abdul Alrasheed (AA) what they thought of building the Fonolo client.
AG: What sparked your initial interest in Android?
JSJ: I became interested in Android after my excitement about the iPhone was replaced with the reality that their market is flooded with applications, and that I would be limiting my work to a single carrier and device. Android promised an open source alternative that has plenty of public interest and good commercial backing as well. The fact that Android has a marketplace to simplify the distribution process, and registering as a developer was a one time fee of $25 rather than whatever ridiculous rate Apple charges definitely also contributed to my interest. Additionally I was already familiar with Java and wouldn’t have to learn Objective C.
CG: I wanted something that wasn’t the iPhone. I was a T-Mobile subscriber and wanted something like the iPhone but didn’t want to change providers. When I heard that the G1 was Java-based, that was it.
AA: What makes Android interesting is the simplicity and the use of Java.
AG: What led you to create a Fonolo application, instead of something else?
JSJ: The Fonolo project was a perfect fit for the requirements of the Software Engineering class I was taking at the University of Oregon at the time. We had to develop an automated system for bypassing phone menus and getting straight to an operator. Fonolo already had that functionality, so all we had to do was provide a good interface to use their service through an application on the Android platform. Initially though creating an interface with Fonolo was not our idea. We wanted to actually code the functionality directly on the phone to listen to the other line, determine if whatever was on the other end was a human, and if not attempt to reach a human. The problem with that idea is that Android currently does not support the functionality to record the call itself. We found that the only recording functionality we had access to was the built in microphone, and that was definitely not sufficient to record the other end of the phone call. Since we didn’t have the option of coding the required functionality directly into the phone, we needed some intermediary to do the work, and Fonolo was the perfect match.
AG: What did you find particularly challenging about building this Android application?
JSJ: There were two main things that I found particularly challenging about building this application. The first thing was an error that we kept encountering whenever we sent an HTTP post to Fonolo. Although the application worked fine on the emulator, when we put it on an actual phone we would get an error message requiring us to hit a button which allowed the application to continue to operate. After some investigation we found out that the main thread of execution limits the amount of time a particular method is allowed to execute, and our HTTP post and waiting for the result was definitely going over that time limit.Â We then farmed out the HTTP posting into a background task which refreshes the foreground once the message is received. This fixed the problem but posed a new one in that if the display is rotated while the phone is waiting for a response from Fonolo, the background thread is lost and the request doesn’t get completed.
[quick aside: during the interview, I suggested perhaps moving the HTTP operations to a local service, which does not get restarted when the device gets rotated]
The other main problem was in the HTTP post itself. The Fonolo API is essentially a specification of message passing with their servers via JSON. They have a nice front end for this base level API written in PHP, but to get the application working on Android we had to rewrite the PHP front end in Java. Despite many hours scouring message boards for different methods of doing HTTP posts, which is what I needed to do with the JSON request string, I could not get a properly formatted request to Fonolo and all I received from them was the standard error message. Finally only through trial and error I discovered a deprecated method in the apache library: “org.apache.commons.httpclient.methods.PostMethod” happens to work properly for the communication with Fonolo. I found this method in commons-httpclient-3.1.jar which you can get through Apache.
Up Next: more thoughts from the Fonolo Android client team!
Have an Android development team? Want to share your experiences with the world? Drop us a line, and perhaps you can be profiled in a future interview!