Example #1
0
 private void PhoneCallEnded(DateTime start, DateTime end)
 {
     if (phoneListener != null)
     {
         phoneListener.CallEndedEvent -= PhoneCallEnded;
     }
     telephonyManager.Listen(phoneListener, PhoneStateListenerFlags.None);
     phoneListener = null;
     InjectionManager.SendViewModelMessage(callBackKey, true);
 }
Example #2
0
        public void PlaceCallWithCallBack(string phoneNumber, string callBackKey)
        {
            try
            {
                this.callBackKey              = callBackKey;
                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.ToNumericString(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();
            }
        }