拨打电话

来源:互联网 发布:指尖陀螺推荐 知乎 编辑:程序博客网 时间:2024/04/30 10:21

1.直接拨打

Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"                    + "phone"));            startActivity(intent);

2.跳转到拨号界面

Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:" +             "需要拨打的phone"));             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);             startActivity(intent);

注意:

拨打的电话只能全是数字,去除-
如:

String phone="028-78451235";                phone=phone.replace("-", "");                Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"                        + phone));                startActivity(intent);
0 0