/**
* 拨打电话(跳转到拨号界面,用户手动点击拨打)
*
* @param phoneNum 电话号码
*/
public void diallPhone(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);
}
<uses-permission android:name="android.permission.CALL_PHONE" />
PS:自动拨打电话在6.0以后即使加了权限也会crash,因为动态权限的问题,参考:https://aswifter.com/2015/11/04/android-6-permission/index.html