如何从我的应用程序拨打电话?

时间:2014-12-26 03:27:52

标签: android android-view

需要从我的应用程序拨打电话,而无需调用默认拨号器活动,即我的应用程序的活动应完成拨出,对话和挂断操作。

注意,调用默认拨号器Activity的常用方法如下所示,不是我需要的:

 String nber = phone.getText().toString();
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:" + nber));
        startActivity(callIntent);

2 个答案:

答案 0 :(得分:1)

试试这个

    String nber = "tel:" + phone.getText().toString().trim();
    Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(nber)); 
    startActivity(callIntent);

并给予清单许可

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

答案 1 :(得分:0)

Intent calltoDoctor = new Intent(Intent.ACTION_CALL);
calltoDoctor.setData(Uri.parse("tel:" + personalInformation.getEmgyno()));
startActivity(calltoDoctor);

在清单中添加权限。

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

试试这个

相关问题