我已经创建了Xamarin Forms应用程序,并且需要以编程方式关闭通话。我正在寻找这个看似简单的问题的解决方案,但找不到任何东西。有人可以帮忙。如果您需要更多信息,请告诉我,我会提供。不知道这是否足够的信息。谢谢。我将代码放在下面:
public bool CallInProgress()
{
var telephonyManagerService = (TelephonyManager)Xamarin.Forms.Forms.Context.GetSystemService(Context.TelephonyService);
var getCurrentState = telephonyManagerService?.CallState;
if (getCurrentState.ToString().ToUpper() == CallState.Idle.ToString().ToUpper())
{
return false;
}
else
{
return true;
}
}
public void EndCurrentCall()
{
if (CallInProgress())
{
//Need the code here to end the current call
}
}