1、只调用拨号界面,不拨出电话
- @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_DIAL,Uri.parse("tel:"+phone));
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- }
调用后就能跳转到拨号界面了
2、跳过拨号界面,直接拨打电话
- @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);
- }
记得添加权限: [html] view plain copy
- <uses-permission android:name="android.permission.CALL_PHONE" />