0

I'm trying to make a dialer intent and getting this error: Android.Content.ActivityNotFoundException: 'No Activity found to handle Intent { act=android.intent.action.DIAL dat=tel:xxxxxxxxxx }' This is my code:

Intent intent = new Intent();
intent.SetAction(Intent.ActionDial);
Android.Net.Uri uri = Android.Net.Uri.Parse("tel:" + "1700700848");
intent.SetData(uri);
StartActivity(intent)

I have tried to find a solution to this problem but nothing worked.

  • Does this answer your question? [How to make a phone call using intent in Android?](https://stackoverflow.com/questions/4275678/how-to-make-a-phone-call-using-intent-in-android) – Ajay K S Feb 15 '22 at 07:21

3 Answers3

0

Try this code i think this will help you

Android.Net.Uri uri = Android.Net.Uri.Parse("tel:" + "1700700848");
Intent intent = new Intent(Intent.ACTION_DIAL, uri);
startActivity(intent);

this question is already answered here

Ajay K S
  • 350
  • 1
  • 5
  • 16
0

Well, there are two ways to do this in Xamarin Android as of now:

  • Using intent:

    Intent intent = new Intent();
    intent.SetAction(Intent.ActionDial);
    Android.Net.Uri uri = Android.Net.Uri.Parse("tel:" + "1700700848");
    intent.SetData(uri);
    activityContext.StartActivity(intent);
    
  • Xamarin Essentials:

    In your Manifest add:

If your project's Target Android version is set to Android 11 (R API 30) you must update your Android Manifest

  <queries>
  <intent>
  <action android:name="android.intent.action.DIAL" />
  <data android:scheme="tel"/>
  </intent>
  </queries>

And create a method like below:

 public void PlacePhoneCall(string number)
{
    try
    {
        PhoneDialer.Open(number);
    }
    catch (ArgumentNullException anEx)
    {
        // Number was null or white space
    }
    catch (FeatureNotSupportedException ex)
    {
        // Phone Dialer is not supported on this device.
    }
    catch (Exception ex)
    {
        // Other error has occurred.
    }
}

Then use it something like this: PlacePhoneCall(399287934);

Dharman
  • 30,962
  • 25
  • 85
  • 135
FreakyAli
  • 13,349
  • 3
  • 23
  • 63
0

In Xamarin, you can use Xamarin.Essentials: Phone Dialer. Just add a simple configuration under the AndroidManifest.xml asking price and you can use it.

More information about it can refer to: https://learn.microsoft.com/en-us/xamarin/essentials/phone-dialer?tabs=android.

Wen xu Li
  • 1,698
  • 1
  • 4
  • 7