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 <LinearLayoutxmlns: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: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= "@dimen/activity_vertical_margin"Ten Tools:context=". Phoneactivity " > One A <TextView - Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" the Android:text= "Please enter the phone" /> - - <EditText - Android:id= "@+id/edittext1" + Android:layout_width= "Fill_parent" - Android:layout_height= "Wrap_content" + Android:inputtype= "Phone" /> A at <Button - Android:id= "@+id/callsumbit" - Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" - android:layout_gravity= "Center" - Android:text= "Call" /> in - </LinearLayout>

Create method for Callactivity

1 protected voidonCreate (Bundle savedinstancestate) {2         Super. OnCreate (savedinstancestate);3 Setcontentview (r.layout.activity_call);4Button BTN =(Button) Findviewbyid (r.id.callsumbit);5Btn.setonclicklistener (NewOnclicklistener () {6 7 @Override8              Public voidOnClick (View v) {9EditText Etnumber =(EditText) Findviewbyid (R.ID.EDITTEXT1);Ten  OneString number =Etnumber.gettext (). toString (); AIntent Intent =NewIntent (); - intent.setaction (intent.action_call); -Intent.setdata (Uri.parse ("Tel:" +Number )); the startactivity (intent); -             } -         }); -}

Increase access to calls: Androidmanifest.xml

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Manifestxmlns:android= "Http://schemas.android.com/apk/res/android"3  Package= "Com.ccec.callphone"4 Android:versioncode= "1"5 Android:versionname= "1.0" >6 7     <USES-SDK8         android:minsdkversion= "8"9 android:targetsdkversion= "+" />Ten     <uses-permissionAndroid:name= "Android.permission.CALL_PHONE"/> One  A     <Application -         Android:allowbackup= "true" - Android:icon= "@drawable/ic_launcher" the Android:label= "@string/app_name" - Android:theme= "@style/apptheme" > -         <Activity -             Android:name= "Com.ccec.callphone.CallActivity" + Android:label= "@string/app_name" > -             <Intent-filter> +                 <ActionAndroid:name= "Android.intent.action.MAIN" /> A  at                 <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> -             </Intent-filter> -         </Activity> -     </Application> -  - </Manifest>

Dial-up functionality can now be implemented.

Simple implementation of Android dialer

Related Article

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.