拨打电话点击一个按钮 [英] make a phone call click on a button

查看:27
本文介绍了拨打电话点击一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我按下 android 中的按钮时,我正在尝试拨打电话

I'm trying to make a call when I press a button in android

((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
    String phno="10digits";

    Intent i=new Intent(Intent.ACTION_DIAL,Uri.parse(phno));
    startActivity(i);
  }
});

但是当我运行并单击按钮时,它给了我错误

But when I run and click on the button it gives me the error

ERROR/AndroidRuntime(1021): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL dat=9392438004 }

我该如何解决这个问题?

How can I resolve this problem?

推荐答案

您是否在清单文件中赋予了权限

Have you given the permission in the manifest file

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

在你的活动中

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

如果您发现任何问题,请告诉我.

Let me know if you find any issue.

这篇关于拨打电话点击一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆