android拨打电话

添加权限:

<uses-permission android:name="android.permission.CALL_PHONE"/>

 核心代码:

private void callPhone() {
String phoneNumber = numberText.getText().toString().trim() ;
if(TextUtils.isEmpty(phoneNumber)){
Toast.makeText(getApplicationContext(), "号码不能为空", Toast.LENGTH_SHORT).show() ;
return ;
}
Intent intent = new Intent() ;
intent.setAction(Intent.ACTION_CALL) ;
intent.setData(Uri.parse("tel:"+phoneNumber)) ;
startActivity(intent) ;
}

 

你可能感兴趣的:(android)