Telephony Services in Android
In today's video our topic is Telephony Services in Android.
Telephony Services we use basically for Calling or SMS applications. For this we need to use TelephonyManager API.
TelephonyManager API enables us to access the native telephony services available or create a user defined telephony application.
TelephonyManager Class is used to determine telephony services and states - IDLE, RINGING, DATA_CONNECTED...
Application can register to receive notification of state changes.
Some telephony information needs permission to be set in the manifest - <uses permission android name="android permission.READ_PHONE_STATE>
The best practice is to use Intents to launch a dialer application to initiate new phone calls. There are two Intent actions you can use to dial a number.
Intent.ACTION_CALL automatically initiates the call, displaying the in call application. We should only use this action if we are replacing the native dialer.
Intent.ACTION_DIAL rather than dial the number immediately, this action starts a dialer application, passing in the specified number but allowing the dialer application to manage the call initialization. This action doesn't require any permissions and is the standard way applications should initiate cells.
The following skeleton code shows the Basic technique for dialling a number,
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:1234567"));
We can monitor the changes in mobile data connectivity and mobile data transfer by implementing a PhoneStateListener.
Override onDataActivity to track data transfer activity, and onDataConnectionStateChanged to request notifications for data connection state changes.
Have a friend to whom you would want to share this course?