Today i am going to share the code of Action dial in android. 
Phone dialer is an activity available with Android operating system to call a number. In this article, we will create an application which invokes the dialer on a button click. Android system provides a standard action name called “ACTION_DIAL” to invoke the dialer. We will make use this action to invoke the the dialer from our application.
 
   
Phone dialer is an activity available with Android operating system to call a number. In this article, we will create an application which invokes the dialer on a button click. Android system provides a standard action name called “ACTION_DIAL” to invoke the dialer. We will make use this action to invoke the the dialer from our application.
Main.xml
| 
1 
2 
3 
4 
5 | <linearlayout android:layout_height="fill_parent"android:layout_width="fill_parent"android:orientation="vertical"xmlns:android="http://schemas.android.com/apk/res/android"> <button android:id="@+id/btn"android:layout_height="wrap_content"android:layout_width="fill_parent"android:text="@string/dialer"> </button></linearlayout> | 
MainActivity.java
| 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 | package com.sunil.dial;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class MainActivity extends Activity {    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);              Button btn  = (Button) findViewById(R.id.btn);                       OnClickListener listener = newOnClickListener() {      @Override   public void onClick(View v) {        Intent intent = newIntent("android.intent.action.DIAL");    startActivity(intent);   }  };                btn.setOnClickListener(listener);    }} | 
 
  
 
No comments:
Post a Comment