Use implicit intent to invoke system dialing, calling program

Source: Internet
Author: User

Action


• Dial Action:intent. Action_dial
• Call Action:intent. Action_call


Permission
• In Android, sensitive operations (privacy-related, secure, and may incur costs)
Requires permission and, before the application is installed on the device, enumerates the permissions requested by the current application, and the user can choose to continue installing the application or not.

• Call permissions are:

<uses-permission android:name= "Android.permission.CALL_PHONE"/>


The first step in mainactivity:

Package Com.example.intent_intentfilter;import Android.net.uri;import Android.os.bundle;import Android.app.activity;import Android.content.intent;import Android.view.menu;import Android.view.View;import Android.view.view.onclicklistener;import Android.widget.button;import Android.widget.edittext;public Class Mainactivity extends Activity {private EditText et_phonenumber;private Button Btn_dial,btn_call; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_ Main); et_phonenumber = (EditText) Findviewbyid (r.id.et_phonenumber); btn_call = (Button) Findviewbyid (R.id.btn_call); Btn_dial = (Button) Findviewbyid (r.id.btn_dial); Inneronclicklistener listener = new Inneronclicklistener (); btn_ Call.setonclicklistener (listener); Btn_dial.setonclicklistener (listener);} Private class Inneronclicklistener implements onclicklistener{@Overridepublic void OnClick (View v) {//TODO Auto-generated method Stubintent Intent = new intent (); StRing PhoneNumber = Et_phonenumber.gettext (). toString (); The string format for//data is: Tel://10086intent.setdata (Uri.parse ("tel://" +phonenumber)); switch (V.getid ()) {case r.id.btn_call:intent.setaction (intent.action_call); Break;case R.id.btn_ Dial:intent.setAction (intent.action_dial); break;default:break;}}}
Step Two: Add permissions to the configuration file:

<uses-permission android:name= "Android.permission.CALL_PHONE"/>

Use implicit intent to invoke system dialing, calling program

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.