a Caller ID that speaks (for Android)

So I have just arrived home and while preparing a tuna fish sandwich somebody calls home and the answer machine started to say the number. This is something very normal as I had this answer machine for 5 years more or less. The first days it was amazing to be 20 meters away from the phone and listen the phone number of the person who was calling me. It is very nice, it prevents me and my family from running to the phone every time somebody calls.
So I was thinking about doing the same for a cellphone, and I am sure there are a few apps out there that does this. But I wanted to do it in a few minutes and post the code.
I choose Android as the platform as I think it is flexible enough to archive this task. This cannot be done in iPhone with such a limited API and no access to key features of the phone.
Basically you need to register a Listener which will handle “Phone State Changes”. If one of those events indicates a “Phone ringing” you have to parse the number digit by digit and play an audio file.
The audio you will find in this example is my voice, and the numbers are in German (just to make this a bit funnier, and to practice, of course).
This application does not have an activity. It has only two classes, a Broadcast Receiver and a Service. The Broadcast Receiver it will lunch the Service as soon as the phone finished booting. The Service will register a Listener to the Telephony Manager, and that Listener will handle the incoming call.
How to register the Listener for Incoming Calls

How to handle an Incoming Call event

The complete project

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s