调起打电话界面

关于Intent , 安卓系统中有很多内置的action, 电话也是其中的一种

拨打电话,对于用户来说,是一个耗费的操作,因此,需要一定权限,就是android.permission.CALL_PHONE权限,我们需要在AndroidMenifest文件里加上这个权限:。
第一种方法,拨打电话跳转到拨号界面。源代码如下:

Intent intent = new Intent(Intent.ACTION_DIAL);
Uri data = Uri.parse("tel:" + "135xxxxxxxx");
intent.setData(data);
startActivity(intent);

第二种方法,拨打电话直接进行拨打,但是有些第三方rom(例如:MIUI),不会直接进行拨打,而是要用户进行选择是否拨打,源代码如下:

Intent intent = new Intent(Intent.ACTION_CALL);
Uri data = Uri.parse("tel:" + "135xxxxxxxx");
intent.setData(data);
startActivity(intent);

关于intent的 action type data 以后有时间补充

猜你喜欢

转载自blog.csdn.net/xiaoxiaodechongzi/article/details/77520636