In some cases, we may need to make a phone call using our program, which Android has built-in applications for. This might be accomplished quickly by combining implicit Intent with the required actions. We can also use the PhoneStateListener and TelephonyManager classes to keep track of changes in the device's telephony states.
The ACTION_CALL action will be used to activate the Android device's built-in phone call capability. The syntax for creating an intent with the ACTION_CALL action is as follows.
Intent phoneIntent = new Intent (Intent.ACTION_CALL);
Instead of making a straight call, you can use the ACTION DIAL action instead of ACTION_CALL. In this case, you will have the option to edit a hardcoded phone number before making a call.
To make a phone call to the number 91-000-000-0000, use the setData() method and specify tel: as the URI.
phoneIntent.setData (Uri.parse ("tel:91-000-000-0000"));
The fascinating thing is that you don't need to specify any extra data or data type to make a phone call.
The android.telecom package in the Android framework contains classes that let you develop a calling app that adheres to the telecom framework. The following are some of the advantages of developing your app according to the telecom framework:
|