Android Implementation dialing function

Source: Internet
Author: User

Dial-up interface:
  
 
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. android:layout_width="match_parent"
  3. android:layout_height="match_parent"
  4. android:orientation="vertical" >
  5. <!-- match_parent: 匹配父元素,父元素有多宽,我就有多宽;父元素有多高,我就有多高 -->
  6. <!-- wrap_content:包裹内容,我的内容有多高,我就有多高,我的内容有多宽,我就有多宽 -->
  7. <EditText
  8. android:id="@+id/et_input_num"
  9. android:layout_width="match_parent"
  10. android:layout_height="wrap_content"
  11. android:inputType="phone" >
  12. </EditText>
  13. <!-- android:text: 指定按钮上的显示文字 -->
  14. <!-- android:onClick: 定义点击事件 -->
  15. <Button
  16. android:layout_width="wrap_content"
  17. android:layout_height="wrap_content"
  18. android:onClick="call"
  19. android:text="打电话" />
  20. </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

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.