Address: http://uuubd.iteye.com/blog/1387961
There are two key aspects for calling. First, add user-Permission to androidmanifest and declare the permission of Android. Permission. call_phone. As the call is a service at the bottom of the mobile phone, it is closely related to user privacy, call charges, and other information. Therefore, the program must obtain relevant permissions.
package org.hwq.ex5_phone;import android.app.Activity;import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.view.View;import android.widget.Button;public class Main extends Activity {Button b; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); b = (Button) findViewById(R.id.button1); b.setOnClickListener(new Button.OnClickListener(){@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubIntent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:10086"));startActivity(intent);} }); }}
Add the call permission to androidmanifest
<Uses-Permission Android: Name = "android. Permission. call_phone"/>
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.hwq.ex5_phone" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" /> <uses-permission android:name="android.permission.CALL_PHONE"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".Main" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>