Anand
Anand

Reputation: 1959

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);

Upvotes: 3

Views: 3405

Answers (1)

VahidShir
VahidShir

Reputation: 2106

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.

Upvotes: 5

Related Questions