Introduction

Android is one of the most popular operating systems for mobile. In this article, I will show you how to create a Calling Application in Android Using Android Studio.
Requirements
Steps to be followed
Follow these steps to create a Calling Application in Android Using Android Studio. I have included the source code in the attachment.
Step 1
Open Android Studio and start a new Android Studio Project.
Android
Step 2
You can choose your application name and choose where your project is stored on the location. If you wish to use C++ for coding the project, mark the "Include C++ support", and click the "Next" button.
Android
Now, select the version of Android and select the target Android devices.
Android
Step 3
Now, add the activity and click the "Next" button.
Android
Add activity name and click "Finish".
Android
Step 4
Go to activity_main.xml. This XML file contains the designing code for your Android app.
Android
The XML code is given below.
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools"
  5. android:layout_width="match_parent"
  6. android:layout_height="match_parent"
  7. tools:context="abu.call.MainActivity" >
  8. <RelativeLayout
  9. android:layout_width="match_parent"
  10. android:layout_height="wrap_content"
  11. android:orientation="vertical">
  12. <TextView
  13. android:id="@+id/textView1"
  14. android:layout_width="wrap_content"
  15. android:layout_height="wrap_content"
  16. android:text="Dial No." />
  17. <Button
  18. android:id="@+id/button1"
  19. android:layout_width="wrap_content"
  20. android:layout_height="wrap_content"
  21. android:layout_alignLeft="@+id/textView1"
  22. android:layout_below="@+id/textView1"
  23. android:layout_marginLeft="44dp"
  24. android:layout_marginTop="84dp"
  25. android:text="Call" />
  26. <EditText
  27. android:id="@+id/editText1"
  28. android:layout_width="wrap_content"
  29. android:layout_height="wrap_content"
  30. android:layout_alignLeft="@+id/textView1"
  31. android:layout_below="@+id/textView1"
  32. android:layout_marginLeft="18dp"
  33. android:ems="10" >
  34. <requestFocus />
  35. </EditText>
  36. </RelativeLayout>
  37. </android.support.constraint.ConstraintLayout>
Step 5
Go to Main Activity.java. This Java program is the backend language of the Android app.
Android
The Java code is given below
  1. package abu.call;
  2. import android.Manifest;
  3. import android.content.pm.PackageManager;
  4. import android.net.Uri;
  5. import android.os.Bundle;
  6. import android.app.Activity;
  7. import android.content.Intent;
  8. import android.support.v4.app.ActivityCompat;
  9. import android.view.Menu;
  10. import android.view.View;
  11. import android.view.View.OnClickListener;
  12. import android.widget.Button;
  13. import android.widget.EditText;
  14. public class MainActivity extends Activity
  15. {
  16. EditText et;
  17. Button call_btn;
  18. @Override
  19. protected void onCreate(Bundle savedInstanceState)
  20. {
  21. super.onCreate(savedInstanceState);
  22. setContentView(R.layout.activity_main);
  23. et=(EditText)findViewById(R.id.editText1);
  24. call_btn=(Button)findViewById(R.id.button1);
  25. call_btn.setOnClickListener(new OnClickListener()
  26. {
  27. @Override
  28. public void onClick(View v)
  29. {
  30. // TODO Auto-generated method stub
  31. Intent i = new Intent(Intent.ACTION_CALL);
  32. i.setData(Uri.parse("tel:"+et.getText().toString()));
  33. startActivity(i);
  34. }
  35. });
  36. }
  37. }
Step 6
We need to make call requests, so add call permissions in AndroidManifest.xml.
Android
The AndroidManifest.xml code is given below.
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="abu.call">
  4. <uses-permission android:name="android.permission.CALL_PHONE" />
  5. <application
  6. android:allowBackup="true"
  7. android:icon="@mipmap/ic_launcher"
  8. android:label="@string/app_name"
  9. android:roundIcon="@mipmap/ic_launcher_round"
  10. android:supportsRtl="true"
  11. android:theme="@style/AppTheme">
  12. <activity android:name=".MainActivity">
  13. <intent-filter>
  14. <action android:name="android.intent.action.MAIN" />
  15. <category android:name="android.intent.category.LAUNCHER" />
  16. </intent-filter>
  17. </activity>
  18. </application>
  19. </manifest>
Step 7
Now, go to the menu bar and click "Make Project" or press ctrl+f9 so as to debug it from errors.
Android
Step 8
Then, click the "Run" button or press shift+f10 to run the project. Choose the "virtual machine" option and click OK.
Android

Conclusion

We have successfully created a Calling application in Android using Android Studio.
Android
Android