Android Tutorial

(avery) #1

By : Ketan Bhimani


394 

Using Android Telephony APIs

Although the Android platform has been designed to run on almost
any type of device, the Android devices available on the market are
primarily phones. Applications can take advantage of this fact by
integrating phone features into their feature set.

This chapter introduces you to the telephony-related APIs available
within the Android SDK.

Working with Telephony Utilities

The Android SDK provides a number of useful utilities for
applications to integrate phone features available on the device.
Generally speaking, developers should consider an Android device
first and foremost as a phone. Although these devices might also
run applications, phone operations generally take precedence. Your
application should not interrupt a phone conversation, for example.
To avoid this kind of behavior, your application should know
something about what the user is doing, so that it can react
differently. For instance, an application might query the state of the
phone and determine that the user is talking on the phone and
then choose to vibrate instead of play an alarm.

In other cases, applications might need to place a call or send a
text message. Phones typically support a Short Message Service
(SMS), which is popular for texting (text messaging). Enabling the
capability to leverage this feature from an application can enhance
the appeal of the application and add features that can’t be easily
replicated on a desktop environment. Because many Android
devices are phones, applications frequently deal with phone
numbers and the contacts database; some might want to access
the phone dialer to place calls or check phone status information.
Free download pdf