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