Intent 拨号

权限:<uses-permission android:name="android.permission.CALL_PHONE"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public void gotoCall(View v)
{
EditText et = findViewById(R.id.phone);
String num = et.getText().toString();
if (num.equals(""))
Toast.makeText(this, "no num", Toast.LENGTH_SHORT).show();
else
startCall(num);
}

public void startCall(String num)
{
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + num));
startActivity(intent);
}