Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.forms make phone call without going to dialer in Android

In my Xamarin.forms app, I can call a specified phone number using Xamarin.Essential plugin. The problem I am facing is, when I click to call on my app in Android it will open the phone dialer and the user should manually click call.

In iOS, it will directly place a call without going to the dialer. What my intention is to prevent editing of the number in the dialer.

So, How can I call the number without going into dialer instead it should show calling screen directly in android? I have seen many posts, but I didn't get any ideas. Any help is appreciated.

I am making a call using xamarin.Essential plugin like this

PhoneDialer.Open(PhoneNumber.Text);
like image 785
Anand Avatar asked Dec 27 '25 14:12

Anand


1 Answers

To place a phone call directly, you can use Xam.Plugins.Messaging library:

After installing the nuget, add this line in Android project MainActivity's OnCreate method:

CrossMessaging.Current.Settings().Phone.AutoDial = true;

Now you can place any call directly like below:

var phoneDialer = CrossMessaging.Current.PhoneDialer;
if (phoneDialer.CanMakePhoneCall)
   phoneDialer.MakePhoneCall("+27219333000");

Please note using this settings requires the android.permission.CALL_PHONE added to the manifest file.

like image 112
VahidShir Avatar answered Dec 31 '25 19:12

VahidShir