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.
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
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);
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.