Only Dial a phone number in android programmatically

How to dynamically send mobile phone number from android app to dial window screen on button click.

In this tutorial we are simply creating a android application project with mobile phone number dial functionality, Means android app developer can add his own number or the company’s contact number inside android app and when user clicks on button then it will automatically transfer the contact number to android phone’s number dial screen, So user can also save the contact from there and also make a call if he wants to. So here is the complete step by step tutorial for Only Dial a phone number in android programmatically.

android-project-download-code-button

How to Only Dial a phone number in android programmatically.

Code for MainActivity.java file.

 package com.dialphonenumber_android_examples.com;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

 Button dial;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 
 dial = (Button)findViewById(R.id.button1);
 
 dial.setOnClickListener(new View.OnClickListener() {
 
 @Override
 public void onClick(View v) {
 // TODO Auto-generated method stub
 
 Intent intent = new Intent(android.content.Intent.ACTION_DIAL, Uri.parse("tel:+911234567890"));
 startActivity(intent);
 
 }
 });
 }
}

Code for activity_main.xml layout 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:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context="com.dialphonenumber_android_examples.com.MainActivity" >

 <Button
 android:id="@+id/button1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_centerHorizontal="true"
 android:layout_centerVertical="true"
 android:text="Click here to Only Dial a phone number in android programmatically" />

</RelativeLayout>

Screenshots:

dial-1

 

Only Dial a phone number in android programmatically

Click here to download Only Dial a phone number in android programmatically project with source code.

Leave a Reply

Your email address will not be published. Required fields are marked *