Cellphone text messaging

James Vanderhyde
Benedictine College

Contents

  1. Meta-information
  2. Resources
  3. Commentary

Meta-information

Summary Cellphone Text Messaging: build a telephone GUI on a PC and use it to send texts to your (or another’s) phone.
Topics GUI building (Java containers and layouts), use of preexisting classes.
Audience Appropriate for middle of a CS1 course.
Difficulty This is a moderate lab, doable by most students in one (75-minute) lab session.
Strengths This assignment generates a lot of excitement when the students get to the end and see their messages appearing on their phones. It includes good practice with building GUIs for something useful. Only a little provided code is necessary.
Weaknesses Requries a network connection in the lab, requires a server somewhere running php and mail, requires quick instructor response for unanticipated cell carriers. It is possible that not everyone has a cell phone.
Dependencies This project is based in Java, though it could be adapted to other environments.
Requires knowledge of elementary GUI elements (buttons, text fields, panels), layout managers, and events. Requires experience instatiating and using existing classes.
Does not require students to know any PHP or any web service concepts.
Variants Clever students could have written some of the supporting classes. Interested students can set this up on their own server. One extension of this project could allow more information to be sent from the client, such as a reply-to number. A different extension would be more GUI controls, such as a clear button.

Resources

Commentary

Motivation

The motivation for this assignment was an opportunity for the students to write code for different layout managers to create a graphical user interface. The inspiration came from Bloss and Ingram’s lab manual for Lewis and Loftus’ Java Software Solutions. (I will have to ask copyright permission for this.) The task as presented in the lab manual was to create a GUI for a telephone keypad. This is a little bit interesting, but the keypad doesn’t do anything. I thought students would like it better if it did something. Since they love text messaging, that would be a good application.

The lab is split into three tasks. The first task is to create the numeric keypad and a title. The second task is to use a provided GUI object that records the keypad clicks in a label. (I provided this class for them to save time, but advanced students could have implemented it themselves.) The third task was to add another provided GUI object that contained a text field and a button. Clicking the button sends the text in the field to the number entered (via an email sent by a web server).

The students were very excited about this project. When they saw the faster students doing something with their cellphones, the plunged ahead to finish the GUI quickly.

How it works

An often-overlooked feature of SMS text messaging is that there is an email address associated with each phone number, such as xxxxxxxxxx@txt.att.net for AT&T wireless number xxx-xxx-xxxx. It was fairly easy to set up a PHP script that would send an email to that address, and it was easy to write a Java method to access a URL to activate the script.

Problems and how to surmount them

I had to host the PHP and mail services on my home computer, because our department does not have a server available to it. I think most departments have an internal server that could be used for this lab. It doesn’t necessarily even have to run PHP. Instructions for setting up the server on Mac OS X can be found for 10.6 and 10.7 or for 10.8. (These are external links; I have not tested the instructions.)

Each wireless provider has its own format for the email address. Since Verizon does not cover our area, I assumed most students would be using AT&T, and I only created a script for AT&T’s format. I was partially correct. AT&T was the most common provider, but there was a plethora of other providers that needed their own handling on the server end. I dealt with this in the lab by maintaining a remote login to my server and creating the necessary new scripts on the fly. I had each student find the format of their provider and tell me what it was. They also had to update their Java source to match the URL of the new file I had created.

One problem with the messaging is that SMS replies go to the sender of the email, which in this case was my server. I collected all the replies and showed them to the entire class the next day. It might have been a little embarrassing to the students, but in a fun way. (Most of the replies had no name attached, only a phone number.)

It is possible that not everyone will have a cell phone. In my class of 24, I had one student who didn’t have a phone, and one student whose phone was broken that day. I found another student who had an unlimited text plan, and I asked him to let them try to send a message to his phone to test their programs.