Working with the Telephony Manager

The telephony APIs also include the telephony manager (android.telephony.TelephonyManager), which you can use to obtain information about the telephony services on the device, get subscriber information, and register for telephony state changes. A common telephony use case requires that an application execute business logic on incoming phone calls. For example, a music player might pause itself for an incoming call and resume when the call has been completed. The easiest way to listen for phone state changes is to implement a broadcast receiver on android.intent.action.PHONE_STATE. You could do this in the same way we listened for incoming SMS messages earlier. The other way is to use TelephonyManager.

In this ...

Get Pro Android 4 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.