1

Monotouch 有什么方法可以读取电话或呼叫者服务的当前状态吗?

如果通话处于活动状态或通话处于保持状态等,我试图找到某种阅读方式。

谷歌搜索这个没有出现任何东西。

正在寻找运行一些代码片段,例如:

if(CallIsActive) {

}
else {

}

我的解决方案:

public static class CallHandler
{
private static CTCallCenter ctc;
private static NSSet calls;

public static void StartListening() {
    Console.WriteLine ("Callhandler is listening");
    ctc = new CTCallCenter ();
    calls = ctc.CurrentCalls;
    ctc.CallEventHandler = new CTCallEventHandler (delegate(CTCall inCTcall) {
            calls = ctc.CurrentCalls;

    });
    }

    public static uint CallCount {
        get {
            return (calls != null) ? calls.Count : 0;
        }
    }

    public static string GetCallState(int CallID) {
        CTCall[] callArr = calls.ToArray<CTCall>();
        CTCall call = callArr[CallID];
        return call.CallState;

    }
}

运行 CallHandler.CallCount 以获取当前呼叫计数和 GetCallState(0) 以进行首次呼叫等。

4

1 回答 1

1

我认为您正在寻找 CoreTelephony 框架。有一个涵盖它的 Apple样本。

using block-based event handlers to receive call events and carrier changes.

您需要将代码从 ObjectiveC 转换为 C#(查找callStateToUser)。

于 2011-09-07T11:58:56.220 回答