方式一 : 调用拨打电话界面
/**
* 拨打电话
*/
private void goCall(String phoneNum) {
if (phoneNum != null) {
Uri phone = Uri.parse("tel:" + phoneNum);
Intent intent = new Intent(Intent.ACTION_DIAL, phone);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
方式二: 直接拨打电话
2.1 加入权限
<uses-permission android:name="android.permission.CALL_PHONE" />
2.2 用startActivity()方式启动拨打电话界面
/**
* 拨打电话
*/
private void goCall(String phoneNum) {
if (phoneNum != null) {
Uri phone = Uri.parse("tel:" + phoneNum);
Intent intent = new Intent(Intent.ACTION_CALL, phone);
startActivity(intent);
}
}