Bus Times On Your Cellphone #
Perhaps it's a sign that my middle class life is becoming too cushy if bus schedules are a significant enough annoyance that I decide to do something about them. Then again, we are talking about the bus (and not my private limo) so I can't be too spoiled. At any rate, this scenario is very representative of the problem:
After a day in the city, I am heading back to the Port Authority terminal. A decision must then be made: should I hurry to the gate on the chance that there's a bus waiting there, or should I take my time, stop off at the Au Bon Pain, restroom, etc. The bus does in fact have a schedule, but it is a hassle to remember to bring it, pull it out at the appropriate time, and locate the next departing bus in a page full of numbers. The annoyance is doubled by the fact that there two bus lines which I could possibly take, thus there is a need to check two schedules, carry two pieces of paper, etc.
In theory the solution would be simple: an electronic display at the entrance to the terminal, showing the next departing bus from each gate. Perhaps even a NextBus-powered one, but that would be asking too much. In the absence of such a convenience, I am forced to take matters into my own hands. The one item that I am much less likely to forget to take with me is my cellphone, thus a solution involving it seems reasonable. The schedule is in fact available on-line, so an approach similar to the one I chose for my cellphone-based dictionary is a possibility. However, the latency of sending out a SMS message and waiting for a response is too great for a time-critical situation such as this one.
A non-networked, local, approach is therefore preferable. My T610 is Java-enabled, supporting MIDP 1.0, so writing a simple Java app seems reasonable. Searching turned up this article, showing how to do MIDP development on Mac OS X. Compiling the "Hello World" example worked fine, modulo the need to not have any spaces in the path to the MIDP installation. As the article mentions, deployment can be done via Bluetooth, and indeed transferring the JAR file resulted in the application showing up in the "Games & More" category. Transferring the JAD didn't seem to work however (the phone didn't know what to do with it), so I had to give up the use of resources/properties that the original "Hello World" app made use of. Considering that this is a one-off application, it's not that big of a deal.
All that was left was to actually write the application, which I cobbled together from this article that explains the basic GUI concepts, while the MIDP 1.0 spec filled in the details. The only gotcha encountered was that, when running on the emulator, the Calendar
instance returned by Calendar.getInstance()
was set to GMT time. However, when running on the phone it did use the local timezone, so only testing was made a bit more difficult. There was also the minor annoyance that the Mac/phone Bluetooth pairing would be lost after every transfer, but I'm not sure where the blame for that lies.
The BusTimes.jar is ready for deployment on a phone, while the complete source package is available as well (the picture shows roughly what to expect when running it). There is support for Saturday/Sunday schedules, but holiday computation wasn't added. In the event of a schedule change, things may get a bit tedious, but that doesn't happen too often.
Now, if only the J2ME implementation in my T610 supported access to Bluetooth and IR. But I guess that's always an excuse to upgrade.
Post a Comment