首页 > 代码库 > Java-Android 之电话拨号源码

Java-Android 之电话拨号源码

file:///F:/workspace3/Android_ver2.4/src/cn/szy/com/MainActivity.java

package cn.szy.com;import android.app.Activity;import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.EditText;public class MainActivity extends Activity { /** Called when the activity is first created. */ private Button button; private EditText edittext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); button = (Button)this.findViewById(R.id.button); edittext = (EditText)this.findViewById(R.id.edittext); } public void Opentall(View v){ String num = edittext.getText().toString(); Intent intent = new Intent(); intent.setAction("android.intent.action.CALL"); intent.setData(Uri.parse("tel:"+ num)); startActivity(intent); }}

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

Java-Android 之电话拨号源码