【问题标题】:No Activity found to handle Intent { act=android.intent.action.CALL dat=+123456789 pkg=com.android.phone }未找到处理 Intent 的 Activity { act=android.intent.action.CALL dat=+123456789 pkg=com.android.phone }
【发布时间】:2016-01-17 11:07:17
【问题描述】:

以下代码在我单击 Activity 中的按钮时可以正常工作,但在单击片段中的按钮时出现“No Activity found to handle Intent”错误。

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

【问题讨论】:

    标签: android


    【解决方案1】:

    我认为您应该说您要添加的数据是这样的电话号码: 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 权限。

    【讨论】:

    • CALL_PHONE 不需要ACTION_DIAL 的权限,只需要ACTION_CALL。见docs
    • @DavidMiguel 我更新了答案。谢谢你的评论。
    【解决方案2】:
            Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse("tel:+123456789"));
            IntentChooser chooser= Intent.createChooser(callIntent,"title")
            startActivity(chooser);
    

    希望对您有所帮助。确保您在清单文件中添加了适当的权限。

    【讨论】:

      【解决方案3】:

      添加此代码将正常工作

      //string phone="034028477736"
      Intent intent=new Intent(Intent.Action-dial,Uri.fromparts("tell",phone,null));
      startactivity(intent);//
      

      【讨论】:

      • 这是取自已接受答案的编码部分。请不要只是复制别人的答案。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-28
      • 1970-01-01
      • 1970-01-01
      • 2012-02-20
      • 2021-03-09
      • 1970-01-01
      相关资源
      最近更新 更多