Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, tutorials, and more.

Chapter 12. Telephone Applications

12.1. Introduction: Telephone Applications

IanDarwin

Discussion

Android began as a platform for cellular telephone handsets, so it is no
surprise that Android apps are very capable of dealing with the phone.
You can write apps that dial the phone, or that guide the user to do so.
You can write apps that verify or modify the number the user is calling
(e.g., to add a long-distance dialing prefix). You can also send and
receive SMS (Short Message Service) messages, a.k.a. text messages, assuming your device is
telephony-equipped. Nowadays, a great many Android tablets are
WiFi-only, and do not have 3G or even 2G telephone/SMS capabilities. For
these devices, other capabilities such as SMS via the Internet and VoIP
(Voice over IP, usually SIP) have to be used.

This chapter covers most of these topics; a few are discussed
elsewhere in this book.

12.2. Doing Something When the Phone Rings

JohanPelgrim

Problem

You want to act on an incoming phone call and do something with the incoming
number.

Solution

You can implement a broadcast receiver and then listen for
a
TelephonyManager.ACTION_PHONE_STATE_CHANGED action.

Discussion

If you want to do something when the phone rings you have to
implement a broadcast receiver, which listens for
the TelephonyManager.ACTION_PHONE_STATE_CHANGED
intent action. This is a broadcast intent action indicating that the
call state (cellular) on the device has changed. Example 12-1 shows the code for the incoming call interceptor, and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, interactive tutorials, and more.