Android uses intent to make calls

Source: Internet
Author: User

Using intent to make calls, we need to increase the call privileges in Anroidmainfest.xml, open this file, add the following in front of the application node
<uses-permission android:name= "Android.permission.CALL_PHONE"/>
Below, use intent to implement this call action, see the code
Intent Intent = new Intent () intent.setaction (Intent.action_call); Intent.setdata (Uri.parse ("tel:15100000000")); StartActivity (Intent);
We are able to put this code in random events, such as the button event. Here is an example to implement.
Button btn = (button) Findviewbyid (R.id.button1); Btn.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stub//textview TV = (TextView) Findviewbyid (R.ID.TEXTVIEW1);// Tv.settext ("very good"), Intent Intent = new Intent (); intent.setaction (Intent.action_call); Intent.setdata (Uri.parse ( "tel:15100000000")); StartActivity (intent);});
The example above is implemented. Click Buttonbtn to trigger the call after the action, the same time to dial out the phone about the user rights issues, please move on Android in the introduction of permissions issues Android permission access to the list of the article

Android uses intent to make calls

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.