In the last article I have discussed about Intent and Types of Intent in the Android Development Tutorial Series. Today we will understand the use of intent to make a phone call in android that will help you in android application development.

An Intent is a messaging object which is use to request functionality/action from other Android components. Intents are generally used to maintain the communication between different android components. An Intent in the Android application is a software mechanism that allows users to coordinate the functions of different activities to achieve a task.

In case if you are not aware of creating a menu in android check this article : Android Menu | Different types of menu in android

Each activity/Component is started or activated with an Intent, which is a message object that makes a request to the Android run-time to start an activity or other app component in your app or in some other app.

Here we will see how to make a phone call in android using intent object .

Only three lines of code is enough to make a phone call using Intent and the action to be performed here is ACTION_DIAL or ACTION_CALL and data to be provided is the phone number, which initiates call explicitly .

We must add the CALL_PHONE permission in the Android Manifest :
<uses-permission android:name="android.permission.CALL_PHONE" />
Dial a number using Intent :

Here, it will open the dialer with the defined phone number from your app by using an Intent object that launches existing phone call clients.

String number = "tel:1234567890" ;
Intent dial = new Intent (Intent.ACTION_DIAL, Uri.parse(number));
Call a number using Intent :

ACTION_CALL action to trigger built-in phone call functionality available in Android device and the syntax is

String number = "tel:1234567890" ;
Intent call = new Intent (Intent.ACTION_CALL, Uri.parse(number));
Difference between ACTION_DIAL or ACTION_CALL :

The major difference between ACTION_DIAL and ACTION_CALL is CALL_PHONE permission . ACTION_DIAL does not require the CALL_PHONE permission.

ACTION_DIAL instead of ACTION_CALL , shows the dialer with the number already entered and allows the user to decide whether to actually make the call or not.

Thank you, Happy Coding…

%d bloggers like this: