0

I have created a Xamarin Forms app and I need to programatically close a call. I have searched for a solution to this seemingly simple problem but can't find anything. Could someone please help. If you require further information, please let me know and I will provide it. Not sure if this is enough info. Thank you. I have placed the code below:

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
    }
}
Irfan
  • 23
  • 5
  • An app that was able to end calls whenever it chose sounds like a great tool for hackers and malware. – Jason Dec 13 '18 at 01:05
  • I assure you its not for that reason at all. I want to place a time limit on the call duration – Irfan Dec 13 '18 at 01:07
  • 1
    You might have good intentions, but other programmers may not. I'm positive Apple does not provide any API for this. Android might - see https://stackoverflow.com/questions/18065144/end-call-in-android-programmatically – Jason Dec 13 '18 at 01:11
  • Thank you. I will take a look at this – Irfan Dec 13 '18 at 18:11

0 Answers0