/*** 拨打电话(跳转到拨号界面,用户手动点击拨打)** @param phoneNum 电话号码*/public void callPhone1(String phoneNum) {Intent intent = new Intent(Intent.ACTION_DIAL);Uri data = Uri.parse("tel:" + phoneNum);intent.setData(data);startActivity(intent);}/*** 拨打电话(直接拨打电话)* @param phoneNum 电话号码*/public void callPhone(String phoneNum){Intent intent = new Intent(Intent.ACTION_CALL);Uri data = Uri.parse("tel:" + phoneNum);intent.setData(data);startActivity(intent);}
// 需添加权限
/**
* 拨打电话
*/
public static void callDial(Context context, String phoneNumber) {context.startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)));
}
添加权限
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE,Manifest.permission.CALL_PHONE,Manifest.permission.RECORD_AUDIO,Manifest.permission.ANSWER_PHONE_CALLS,}, 1);