public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn1=(Button)this.findViewById(R.id.Button01);
btn1.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
EditText et1=(EditText)findViewById(R.id.EditText01);
String mobile=et1.getText().toString();
System.out.println("tel:"+mobile);
Intent intent=new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+mobile));
startActivity(intent);
}
});
}
}
同时,需要在Manifest.XML中配置程序所需的权限
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>