CPSC 110-08: Computing on Mobile Phones
Spring 2012

Phone Raffle App


This app conducts a raffle by randomly selecting a participant's phone number off a list and calling that phone number. It serves as an effective illustration of how easy it is to use App Inventor to develop a truly useful application in a very short time.

It can also be used as a tutorial. As such it illustrates how to use App Inventor's social and communication components. A PhoneCall component is used to make phone calls and a Texting component to send text messages. It uses App Inventor's built-in list blocks to manage a list of phone numbers represented as text values (i.e., strings).

Here's a snap shot of the app's user interface (UI):

As you see it consists of a big Button with a lucky lotto image on it. When the button is clicked the (invisible) PhoneCall component will pick a random phone number off a list and dial it.

In part II, the app will also create a text message, using the invisible Texting component, that will send a message reporting a random prize to the phone. In Part III, we will have the phone receive a text message response from the winner of the raffle.


In order to be able to run this app on your phones, it will be necessary to install a SIM (Subscriber Identity Module) Card.

If your personal cell phone subscription uses a service (ATT, T-Mobile) that uses a SIM card, you can remove it from your personal phone and insert it into your Android phone. However, depending on your service plan, this might result it additional monthly charges depending on whether you (inadvertently or not) use the phone for web surfing.

Another alternative is to purchase a pre paid SIM card. See here for further information.

Basic Set Up, Part I

For the first version of this app we can use two global variables, one to store a list of phone numbers -- the phone numbers of the people taking part in the raffle, and one to store the lucky number that is selected at random:

Making Phone Calls

The behavior of this app is very simple. When the button is pressed, the app will:

We can put the blocks for these operations right into the button click's event handler:

Part II, Sending Text Messages

It is also very easy to write App Inventor code to send text messages. Let's expand our raffle to take advantage of this functionality. We can use the text message to describe a random prize that the winner gets. The prizes can be stored in a prizeList global variable:

For this part of the app, when the button is pressed the app will:

To effect these actions, the following blocks can be added to the button click's event handler:

Part III: Receiving a Text Message

What about receiving text messages? This is also easy to do with App Inventor. Let's suppose we ask the recipient of a prize in our raffle to send a text message to our phone.

App Inventor provides a block to handle an incoming phone call. In this example, we use a Notifier component to put up an alert box announcing the phone call. Notice that this event handler provides both the message and the incoming phone number, which are reported in the notifier:

Download Source

Click here to download the source code and use it for the following exercises.

In-class Exercises, and Homework

  1. Download the zip file and revise the app into a proof-of-concept emergency alert app -- that is, an app that calls all phone numbers on a list to alert users of an emergency situation.

  2. Of course, this is just a simple demo. But what other functionality, beyond proof-of-concept, would be needed to turn it into a truly useful emergency alert app. A database? An online database of emergency information?? A location sensor? Would such an app be doable in App Inventor??