当前位置: 移动技术网 > IT编程>开发语言>c# > c#使用xamarin编写拨打电话程序

c#使用xamarin编写拨打电话程序

2019年07月18日  | 移动技术网IT编程  | 我要评论

xamarin 可以很方便的编写一个电话拨号程序,下面的代码是调用android系统的拨号功能,拨号前会给出一个提示信息。

callbutton是一个用来拨号的按钮,我们使用它的点击事件来进行拨号,拨号前会有一个提示框

callbutton.click += (object sender, eventargs e) =>
{
  // on "call" button click, try to dial phone number. sharejs.com
  var calldialog = new alertdialog.builder(this);
  calldialog.setmessage("call " + translatednumber + "?");
  calldialog.setneutralbutton("call", delegate {
      // create intent to dial phone
      var callintent = new intent(intent.actioncall);
      callintent.setdata(android.net.uri.parse("tel:" + translatednumber));
      startactivity(callintent);
    });
  calldialog.setnegativebutton("cancel", delegate { });
 
  // show the alert dialog to the user and wait for response.
  calldialog.show();
};

以上所述就是本文的全部内容了,希望大家能够喜欢。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网