【发布时间】:2018-12-15 01:05:53
【问题描述】:
最近我尝试在 Visual Studio 2017 中使用 Xamarin 学习 android 编程 我写了一个简单的应用程序来拨打电话,但是当我点击呼叫按钮时,几天前它给出了这个执行错误,但现在我得到了这个错误 我确实在清单文件中允许了 CALL_PHONE 原谅我英语不好 如果有人知道如何解决这个问题,请告诉我我会很高兴 这是我的代码 .cs
using Android.App;
using Android.Widget;
using Android.OS;
using Android.Content;
namespace Dialer.app
{
[Activity(Label = "Dialer.app", MainLauncher = true)]
public class MainActivity : Activity
{
Button btnCall;
ListView txtViewNumbers;
EditText txtUnumber;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
btnCall = FindViewById<Button>(Resource.Id.button1);
txtViewNumbers = FindViewById<ListView>(Resource.Id.listView1);
txtUnumber = FindViewById<EditText>(Resource.Id.editText1);
string phone = txtUnumber.Text;
btnCall.Click += delegate
{
var callDialog = new AlertDialog.Builder(this);
callDialog.SetMessage("Dial This Number? " + phone);
callDialog.SetPositiveButton("ok", delegate
{
var callIntent = new Intent(Intent.ActionCall);
callIntent.SetData(Android.Net.Uri.Parse(phone));
StartActivity(callIntent); //i get error in this line
});
callDialog.SetNeutralButton("Cancel", delegate { });
callDialog.Show();
};
}
}
}
【问题讨论】:
标签: c# xamarin xamarin.android