Exemple #1
0
 public void PlaceCall(string phoneNumber)
 {
     try
     {
         var ctx    = Xamarin.Forms.Forms.Context;
         var intent = new Intent(Intent.ActionCall);
         var uri    = global::Android.Net.Uri.Parse("tel:" + CoreExtensions.CleanPhoneNumber(phoneNumber));
         intent.SetData(uri);
         ctx.StartActivity(intent);
     }
     catch (Exception ex)
     {
         var toast = Toast.MakeText(Xamarin.Forms.Forms.Context, "This activity is not supported", ToastLength.Long);
         toast.Show();
     }
 }
Exemple #2
0
        public void PlaceCallWithCallBack(string phoneNumber)
        {
            try
            {
                var ctx = Xamarin.Forms.Forms.Context;
                phoneListener                 = new PhoneCallListener();
                telephonyManager              = (TelephonyManager)ctx.GetSystemService(Context.TelephonyService);
                phoneListener.CallEndedEvent += PhoneCallEnded;

                telephonyManager.Listen(phoneListener, PhoneStateListenerFlags.CallState);
                var intent = new Intent(Intent.ActionCall);
                var uri    = global::Android.Net.Uri.Parse("tel:" + CoreExtensions.CleanPhoneNumber(phoneNumber));
                intent.SetData(uri);
                ctx.StartActivity(intent);
            }
            catch (Exception ex)
            {
                var toast = Toast.MakeText(Xamarin.Forms.Forms.Context, "This activity is not supported", ToastLength.Long);
                toast.Show();
            }
        }
Exemple #3
0
        public void PlaceCall(string phoneNumber)
        {
            var currentNumber = CoreExtensions.CleanPhoneNumber(phoneNumber);

            if (UIApplication.SharedApplication.CanOpenUrl(new NSUrl("telprompt://" + currentNumber)))
            {
                try
                {
                    UIApplication.SharedApplication.OpenUrl(new NSUrl("telprompt://" + currentNumber));
                }
                catch (Exception ex)
                {
                    var m = ex.Message;
                }
            }
            else
            {
                UIAlertView messageBox = new UIAlertView("Phone Not Enabled", "This device does not support phone calls", null, "Ok", null);
                messageBox.Show();
            }
        }