android - 找不到处理 Intent { act=android.intent.action.CALL dat=+123456789 pkg=com.android.phone } 的 Activity

标签 android

以下代码在我单击 Activity 中的按钮时工作正常,但在单击 fragment 中的按钮时出现“找不到处理 Intent 的 Activity ”错误。

            Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse("+123456789"));
            startActivity(callIntent);

最佳答案

我想你应该说你添加的数据是这样的电话号码: callIntent.setData(Uri.parse("tel:+123456789"));

这是一个完整的解决方案:

首先,将以下权限添加到您的manifest.xml

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

然后使用下面的代码进行调用:

String phone = "+34666777888";
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", phone, null));
startActivity(intent);

更新:

ACTION_DIAL 不需要CALL_PHONE 权限。

关于android - 找不到处理 Intent { act=android.intent.action.CALL dat=+123456789 pkg=com.android.phone } 的 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34837621/

相关文章:

android - Android 应用程序中的离线 openstreetmap 矢量 map

Android:从对话框 fragment 调用 onActivityResult()

android - ActivityManager <user-permission> 权限不起作用

android - SwitchPreferences 多次调用 onPreferenceChange() 方法

android - 错误:Execution failed for task ':dexDebug'

android - DownloadManager 完成后移除 toast

java - Drawer_layout 的 findViewById 始终返回 null

java - 如何清空一个float类型的变量

android - match_parent 不适用于 SherlockFragment 中 listView 的 layout_height

java - 启动时的 Android 警报对话框