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();};
以上所述就是本文的全部內容了,希望大家能夠喜歡。
新聞熱點
疑難解答