Android Phone Call


Android Phone Call

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.

Action to make a phone call is the Intent Object

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.

Data/Type to build a Phone Call Intent Object

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.

Android.telecom package

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:

  • Your program communicates with the device's native telecom subsystem successfully.
  • Your app works well with other calling apps that follow the framework's guidelines.
  • The framework aids in the management of audio and video routing in your app.
  • The framework aids in determining whether or not your app's calls are focused.