Android Phone Calls

Android Phone Calls

Android Phone Calls this chapter is all about this word. We explain you that how you can make phone call step by step. We sure you will understand better. Now we come to our topic. So, Google Android os provides Built-in apps for calls, in a few events we might need to produce a telephone call through our software. This may be done by using implicit Intention with appropriate activities easily. Also, we may use PhoneStateListener and TelephonyManager classes, to be able to keep an eye on the obvious changes in a few telephony areas on these devices.

android phone calls

This Android Phone Calls Tutorial lists down all the easy steps to create an app which is often used to produce a Phone Call. You should use Android Intention to make telephone call by contacting built-in TELEPHONE CALL efficiency of the Android os. Pursuing section explains various areas of our Intent subject necessary to make a call.

Android Phone Calls By Intent Object

You use ACTION_CALL method to result in built-in phone call features available in Android os device. Following is easy syntax to generate an intent with ACTION_CALL action

Intent phoneIntent = new Intent(Intent.ACTION_CALL);

 

You can use ACTION_DIAL action of ACTION_CALL instead, if so you should have option to change hardcoded contact number prior to making a call rather than making a primary call.

Android Phone Calls by Intent Object – Data/Type

In order to make  a phone call at confirmed number 78-000-000-0000, you will need to designate tel: as URI using setData() method the following

phoneIntent.setData(Uri.parse("tel:78-000-000-0000"));

 

The interesting point is the fact that, in order to make a phone call, you certainly do not need to designate any extra data or data type.

Android Phone Call Without Intent

Most of android developer wants to make android phone call without intent and search google that how to make android call without intent and Can i make call in android programmatically without use “Intent”?but there research is all in vain because there is no method to make android phone call without intent and that’s a security feature

Check This:

https://developer.android.com/reference/android/content/Intent.html#ACTION_CALL

https://developer.android.com/reference/android/content/Intent.html#ACTION_DIAL

Android Phone Calls  Example

Following example teaches you in useful how to use Google android Intention to make telephone call to the given mobile amount.

To test out this example, you shall need genuine Mobile device outfitted with latest Android os Operating-system, otherwise you shall have to struggle with emulator which might not exactly work.

Steps    &   Descriptions of Android Phone Calls

1- You use Android studio IDE to set-up an Android request and name it as My Program under a offer com.example.sappal.myapplication. While creating this task, be sure to Concentrate on SDK and Compile With at the latest version of Android os SDK to utilize higher degrees of APIs.

2- Modify src/MainActivity.java and add required code to manage making a call.

3- Modify design XML res/structure/activity_main.xml add any GUI part if required. I’m adding a straightforward button to Call 78-000-000-0000 number

4- No need to identify default string constants.Google android studio manages default constants.

5- Modify AndroidManifest.xml as shown below

6- Run the application form to launch Android os emulator and confirm the consequence of the changes done in the application form.

Following is this content of the improved main activity src/MainActivity.java.

package com.example.sappal.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class MainActivity extends Activity {
   Button b1;
   
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      b1=(Button)findViewById(R.id.button);
      call();
   }
   
   private void call() {
      Intent in=new Intent(Intent.ACTION_CALL,Uri.parse("0000000000"));
      try{
         startActivity(in);
      }
      
      catch (android.content.ActivityNotFoundException ex){
         Toast.makeText(getApplicationContext(),"yourActivity is not founded",Toast.LENGTH_SHORT).show();
      }
   }
   
   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_main, menu);
      return true;
   }
   
   @Override
   public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      
      int id = item.getItemId();
      
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
         return true;
      }
      return super.onOptionsItemSelected(item);
   }
}

 

Following will be the content of res/layout/activity_main.xml file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent" 
   android:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingRight="@dimen/activity_horizontal_margin"
   android:paddingTop="@dimen/activity_vertical_margin"
   android:paddingBottom="@dimen/activity_vertical_margin" 
   tools:context=".MainActivity">
   
   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Drag and Drop Example"
      android:id="@+id/textView"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:textSize="30dp" />
      
   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Andro Development"
      android:id="@+id/textView2"
      android:layout_below="@+id/textView"
      android:layout_centerHorizontal="true"
      android:textSize="30dp"
      android:textColor="#ff14be3c" />
      
   <ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/imageView"
      android:src="@drawable/abc"
      android:layout_marginTop="48dp"
      android:layout_below="@+id/textView2"
      android:layout_centerHorizontal="true" />
      
   <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Call"
      android:id="@+id/button"
      android:layout_below="@+id/imageView"
      android:layout_alignRight="@+id/textView2"
      android:layout_alignEnd="@+id/textView2"
      android:layout_marginTop="54dp"
      android:layout_alignLeft="@+id/imageView"
      android:layout_alignStart="@+id/imageView" />

</RelativeLayout>

 

Following will be the content of res/values/strings.xml to define two new constants

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <string name="app_name">My Application</string>
   <string name="hello_world">Hello world!</string>
   <string name="action_settings">Settings</string>
</resources>

 

Following is the default content of AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.example.sappal.myapplication"
   android:versionCode="1"
   android:versionName="1.0" >
   
   <uses-permission android:name="android.permission.CALL_PHONE" />
   <uses-permission android:name="android.permission.READ_PHONE_STATE" />
   
   <application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" >
      
      <activity
         android:name="com.example.sappal.myapplication.MainActivity"
         android:label="@string/app_name" >
      
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      
      </activity>
      
   </application>
</manifest>

 

Let’s make an effort to run our My Application app. I suppose you have linked your actual Google android Mobile device with your personal computer. To perform the software from Android studio room, available one of your project’s activity data and click Run Eclipse Run  icon from the toolbar. Prior to starting your application, Google android studio room installer will screen following window to choose a choice where you want to perform your Google android application

android phone calls

Choose your mobile device as a choice and check your mobile device that may screen pursuing display screen then

android phone calls

Now use Call button to make telephone call as shown below

android phone calls