为什么即使我的物理设备(OnePlus AC2001 Android11.0 - API-30)中具有该功能,也会抛出 FeatureNotSupportedException?
Why FeatureNotSupportedException is being thrown even though I have the feature in my physical device(OnePlus AC2001 Android11.0 - API-30)?
我正在尝试实现官方 documentation of Microsoft。当我尝试将号码带到拨号页面时,它抛出异常 FeatureNotSupportedException
,根据文档
Exception that occurs when an attempt is made to use a feature on a platform that does not support it.
我正在使用 OnePlus AC2001 Android11.0 - API-30 我相信所有 phone 都必须包含通过 PhoneDialer.Open(translatedNumber)
[=17 拨号的基本功能=]
async void OnCall(object sender, System.EventArgs e)
{
if (await this.DisplayAlert(
"Dial a Number",
"Would you like to call " + translatedNumber + "?",
"Yes",
"No"))
{
try
{
PhoneDialer.Open(translatedNumber);
}
catch (ArgumentNullException)
{
await DisplayAlert("Unable to dial", "Phone number was not valid.", "OK");
}
catch (FeatureNotSupportedException)
{
await DisplayAlert("Unable to dial", "Phone dialing not supported.", "OK");
}
catch (Exception)
{
// Other error has occurred.
await DisplayAlert("Unable to dial", "Phone dialing failed.", "OK");
}
}
}
你读过docs吗?
If your project's Target Android version is set to Android 11 (R API
30) you must update your Android Manifest with queries that are used
with the new package visibility requirements.
Open the AndroidManifest.xml file under the Properties folder and add
the following inside of the manifest node:
<queries>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel"/>
</intent>
</queries>
我正在尝试实现官方 documentation of Microsoft。当我尝试将号码带到拨号页面时,它抛出异常 FeatureNotSupportedException
,根据文档
Exception that occurs when an attempt is made to use a feature on a platform that does not support it.
我正在使用 OnePlus AC2001 Android11.0 - API-30 我相信所有 phone 都必须包含通过 PhoneDialer.Open(translatedNumber)
[=17 拨号的基本功能=]
async void OnCall(object sender, System.EventArgs e)
{
if (await this.DisplayAlert(
"Dial a Number",
"Would you like to call " + translatedNumber + "?",
"Yes",
"No"))
{
try
{
PhoneDialer.Open(translatedNumber);
}
catch (ArgumentNullException)
{
await DisplayAlert("Unable to dial", "Phone number was not valid.", "OK");
}
catch (FeatureNotSupportedException)
{
await DisplayAlert("Unable to dial", "Phone dialing not supported.", "OK");
}
catch (Exception)
{
// Other error has occurred.
await DisplayAlert("Unable to dial", "Phone dialing failed.", "OK");
}
}
}
你读过docs吗?
If your project's Target Android version is set to Android 11 (R API 30) you must update your Android Manifest with queries that are used with the new package visibility requirements.
Open the AndroidManifest.xml file under the Properties folder and add the following inside of the manifest node:
<queries>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel"/>
</intent>
</queries>