Dialing in Android case

Source: Internet
Author: User
Step 1: first in the main. build the dialing interface in the XML file (we recommend that you use a tool to drag it, because it is faster and you do not need to define something in other files) Main. XML <textview Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: text = "@ string/tipmsg"/> <edittext Android: id = "@ + ID/phone" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: inputtype = "phone"> <requestfocus/> </edittext> <button Android: Id = "@ + ID/callbtn" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: text = "@ string/num"/> Step 2: strings under values. XML file <string name = "app_name"> phone </string> <string name = "tipmsg"> enter the correct phone number </string> <string name = "num"> dialing </string> Step 3: in phoneactivity. configure public class phoneactivity extends activity {@ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); // sets the displayed view setcontentview (R. layout. main); // obtain the current view component button callbtn = (button) findviewbyid (R. id. callbtn); callbtn. setonclicklistener (New onclicklistener () {@ overridepublic void onclick (view v) {// edittext phone = (edittext) findviewbyid (R. id. phone); // What is the intention? // obtain the phone in the text box. gettext (); intent = new intent (intent. action_call, Uri. parse ("Tel:" + phone. gettext (); // starts processing the intent to execute phoneactivity. this. startactivity (intent) ;}}) ;}} Step 4: In androidmanifest. add the dialing permission to the XML file (we recommend that you add the permission on the Visual Interface): Open androidmanifest. XML file, click Permissions ---> click Add to add users permission --> select Android In the Name box. permission. call_phone --> Step 5: Right-click to run

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.