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

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

问题描述

我在android应用新程序设计师

i am a new programer in android application

我在我的应用程序中创建一个按钮,当我点击一个按钮,然后我想作一个call.i写了code如下:

i have created a button in my application, when i clicked on a button then i would like to make a call.i have written code as follows

((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);
  }
});

当我运行这个应用程序是显示按钮,当我上单击按钮,然后我得到强制关闭和error.The错误显示在日志猫如下:

when i run this application it is displaying button,when i clicked on button then i am getting force close error.the error showing in log cat as follows

03-23 15:04:16.166: 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...

请帮我

在此先感谢

推荐答案

你给的清单文件的权限

 <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天全站免登陆