Dial-up interface:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!-- match_parent: 匹配父元素,父元素有多宽,我就有多宽;父元素有多高,我就有多高 -->
<!-- wrap_content:包裹内容,我的内容有多高,我就有多高,我的内容有多宽,我就有多宽 -->
<EditText
android:id="@+id/et_input_num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone" >
</EditText>
<!-- android:text: 指定按钮上的显示文字 -->
<!-- android:onClick: 定义点击事件 -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="call"
android:text="打电话" />
</LinearLayout>
//V: The control on your behalfpublic void Call (view view) { EditText EditText = (EditText) Findviewbyid (r.id. Input_num ); //Get the phone number entered by the user StringPhone_number = EditText. GetText (). toString ();//Delete the string header and trailing spaces
Phone_number = Phone_number.trim (); /** * Context: Contexts, Environment <br/> * Text: What to display <br/> * Duration: constant//duration of display * */ Toast. Maketext (this, Phone_number , Toast. Length_long ); if (phone_number! = null &&!phone_number.equals ("")) { //Call system Dial-up service to make phone call function //Call //Intent: intention. I want to do something. Intent t = new Intent (); //Action: action. What exactly do I want to do? //intent.action_dial: Activate Dial-up interface //Intent.action_call: Call directly t.setaction (Intent. Action_call ); //Data: Statistics-additional data required for specific actions //Encapsulates a call intent and wraps the phone number as a URI object .into t.setdata (Uri. Parse ("Tel:" + Phone_number)); //Notification system you go work for me. startactivity (t);} }
finally add in Androidmanifest.xml<uses-permission android:name= "Android.permission.CALL_PHONE"/>
remark:Toast. maketext() consumerMethod1. Default display mode
2. Customize the display position 3. With picture 4. Fully customizable display mode
From for notes (Wiz)
Android Implementation dialing function