Simple implementation of Android dialer

Source: Internet
Author: User

Function implementation: A EditView A dial button, enter the number to jump to the dial-up interface

Interface layout: Activity_call.xml

Linear Vertical layout: One editview text, one button
1 <linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" 2 xmlns:tools= "/HTTP/ Schemas.android.com/tools "3 android:layout_width=" match_parent "4 android:layout_height=" match_parent "5 Android oid:orientation= "vertical" 6 android:paddingbottom= "@dimen/activity_vertical_margin" 7 android:paddingleft= "@dimen /activity_horizontal_margin "8 android:paddingright=" @dimen/activity_horizontal_margin "9 android:paddingTop=" @dim En/activity_vertical_margin "Ten tools:context=". Phoneactivity ">11" <textview13 android:layout_width= "wrap_content" "android:layout_height=" W Rap_content "android:text=" Please enter the phone "/>16" <edittext18 android:id= "@+id/edittext1" Droid:layout_width= "Fill_parent" android:layout_height= "wrap_content" android:inputtype= "Phone"/>2 2 <button24 android:id= "@+id/callsumbit" android:layout_width= "Wrap_content" 26 android:layout_height= "wrap_content" android:layout_gravity= "center" android:text= "call"/>29 30 </LinearLayout>

Create method for Callactivity

1 protected void OnCreate (Bundle savedinstancestate) {2         super.oncreate (savedinstancestate); 3         Setcontentview (R.layout.activity_call); 4         Button btn = (button) Findviewbyid (r.id.callsumbit); 5         Btn.setonclicklistener (new Onclicklistener () {6  7             @Override 8 public             void OnClick (View v) {9                 EditText etnumber = (EditText) Findviewbyid (R.ID.EDITTEXT1); 10 One                 String number = Etnumber.gettext (). toString ();                 Intent Intent = new Intent ();                 intent.setaction ( Intent.action_call);                 Intent.setdata (Uri.parse ("Tel:" + number);                 startactivity (Intent);             }17         }); (+     }

Increase access to calls: Androidmanifest.xml

 1 <?xml version= "1.0" encoding= "Utf-8"?> 2 <manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "3 package=" Com.ccec.callphone "4 android:versioncode=" 1 "5 android:versionname=" 1.0 "> 6 7 &L T;USES-SDK 8 android:minsdkversion= "8" 9 android:targetsdkversion= "" "/>10 <uses-permission and Roid:name= "Android.permission.CALL_PHONE"/>11 <application13 android:allowbackup= "true" and roid:icon= "@drawable/ic_launcher" android:label= "@string/app_name" android:theme= "@style/apptheme" ; <activity18 android:name= "com.ccec.callphone.CallActivity" android:label= "@string  /app_name ">20 <intent-filter>21 <action android:name=" Android.intent.action.MAIN " />22 <category android:name= "Android.intent.category.LAUNCHER"/>24 </intent-f Ilter>25 </activity>26 </application>27 </manifest> 

Dial-up functionality can now be implemented.

Simple implementation of Android dialer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.