我正在尝试在我的 Xamarin.Forms 应用程序中使用电信功能。当调用 AddNewIncomingCall() 时,抛出异常:
Java.Lang.SecurityException: 包 com.android.phone 不属于 10134
这是代码:
Xamarin.Forms.Device.BeginInvokeOnMainThread(async () =>
{
TelecomManager telecomManager = (TelecomManager)Application.Context.GetSystemService(TelecomService);
// https://docs.microsoft.com/en-us/xamarin/essentials/permissions?tabs=android
PermissionStatus status = await Permissions.CheckStatusAsync<ReadPhoneStatePermission>();
if (status != PermissionStatus.Granted)
{
status = await Permissions.RequestAsync<ReadPhoneStatePermission>();
}
PhoneAccountHandle phoneAccountHandle = telecomManager.CallCapablePhoneAccounts.FirstOrDefault();
telecomManager.AddNewIncomingCall(phoneAccountHandle, new Bundle());
});
我该如何解决这个问题?