只调用拨号界面,不拨出电话
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dt_activity_property);
call("12345456");
}
/**
* 调用拨号界面
* @param phone 电话号码
*/
private void call(String phone) {
Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+phone));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
跳过拨号界面,直接拨打电话
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dt_activity_property);
call("057187063728");
}
/**
* 调用拨号功能
* @param phone 电话号码
*/
private void call(String phone) {
Intent intent=new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phone));
startActivity(intent);
}
注意tel要个要求书写格式;
记得添加权限:
<uses-permission android:name="android.permission.CALL_PHONE" />